How can I used of dynamic data of Api for ui-gmap-google-map directory


#1

In most of the example of google map static data is being used like

  $scope.map = {center: {latitude: 51.219053, longitude: 4.404418 }, zoom: 14 };

How can I used for dynamic data which in below format of api
there is no option for ui-gmap-google-map directory where i can attached property of latitude and longitude

 <ui-gmap-google-map center="map.center" zoom="map.zoom" ></ui-gmap-google-map>

var cities = [
{
city : ‘Location 1’,
desc : ‘Test’,
lat : 52.238983,
long : -0.888509
},
{
city : ‘Location 2’,
desc : ‘Test’,
lat : 52.238168,
long : -52.238168
},
{
city : ‘Location 3’,
desc : ‘Test’,
lat : 52.242452,
long : -0.889882
},
{
city : ‘Location 4’,
desc : ‘Test’,
lat : 52.247234,
long : -0.893567
},
{
city : ‘Location 5’,
desc : ‘Test’,
lat : 52.241874,
long : -0.883568
}
];


#2

Not an Ionic question.

Your directive center attribute is bound to cennter attribute of your map in your $scope, so you just have to update it in your controller, so you could call a controller function from your view passing the selected city in argument.

$scope.centerCity = function(city) {
     $scope.map.center = {latitude: city.lat , longitude: city.long };
}