using angular-google-maps to include google map in app
I need a command that will start the ONCE function after the initial loading of the map is completed - but only at the initial loading, not after each manipulation of the map
I can not use idle or tilesloaded , as they are launched after each movement ...
The function I want to run is to get the map borders in order to pull data from the server when the page loads - I want this to happen ONCE on the boot, then do the manual function by updating map-control
- if I use idle or tilesloaded to start it, it will pull out server data every time the user moves the map.
Does anyone know how to run a shutdown command to get map information (borders, etc.) after loading the initial map?
I tried putting maps.getBounds() in the second promise function, but it does not work.
Notice I have a fiddle working here - I just can no longer chain promises after the controls are $scope.map / options, etc., because they do not return a promise:
The sample code in the docs does not show how to bind a promise after defining $scope.map .
HTML
<div class="angular-google-map-container" ng-controller="MainCtrl"> <ui-gmap-google-map center="map.center" zoom="map.zoom" draggable="true" options="map.options" events="map.events" control="googlemap"> </ui-gmap-google-map> </div>
controller
myApp.controller('MainCtrl', function($scope, uiGmapGoogleMapApi) { uiGmapGoogleMapApi .then(function(maps){ $scope.map = { center: { latitude: 37.7749295, longitude: -122.4194155 }, zoom: 12 events: { tilesloaded: function (maps, eventName, args) { myServiceFuntion(maps)
Obviously, the maps object returned by the uiGmapGoogleMapApi promise is completely different from the maps object returned by events such as tilesloaded , etc ... quite confusing.
In addition, the FAQ only indicates how to use tilesloaded to obtain an instance of the map - which does not work for the reasons already described.