You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 25, 2019. It is now read-only.
I need to do geocoding on a map object, and as best I could see, there is no support for "addListenerOnce" and/or the tilesloaded event.
It was trivial to add it. And yes, I know this is NOT elegant. :)
functionbindMapEvents(scope,eventsStr,googleObject,element){// Jason's hack. This makes the "ready" function fire on map load.google.maps.event.addListenerOnce(googleObject,'tilesloaded',function(){scope.ready();});angular.forEach(eventsStr.split(' '),function(eventName){
...
}}
In the controller:
/* ready() is a custom definition that I added to the ui-map code. It sets up a one time listener that will run on 'tilesloaded' */$scope.ready=function(){$scope.getCoords($scope.address1+" "+$scope.city+" "+$scope.selectedState+" "+$scope.zip);};
Not a show stopper, just an FYI.
The text was updated successfully, but these errors were encountered:
I needed something similar, but for the 'idle' event instead. Using your hints, I made something slightly less hacky :)
Essentially, instead of the 'map-' prefix, if the 'map-once-' prefix is used then it is triggered once only. It seems to work, and there aren't any clashes with the event names as far as I know (particularly as the event names use an underscore to separate words).
Let me know if you want me to create a PR for this.
//Setup map events from a google map object to trigger on a given element too,//then we just use ui-event to catch events from an elementfunctionbindMapEvents(scope,eventsStr,googleObject,element){angular.forEach(eventsStr.split(' '),function(eventName){//Prefix all googlemap events with 'map-', so eg 'click' //for the googlemap doesn't interfere with a normal 'click' eventgoogle.maps.event.addListener(googleObject,eventName,function(event){element.triggerHandler('map-'+eventName,event);//We create an $apply if it isn't happening. we need better support for this//We don't want to use timeout because tons of these events fire at once,//and we only need one $applyif(!scope.$$phase)scope.$apply();});//Allow binding to same events once only using the 'map-once-' prefix insteadgoogle.maps.event.addListenerOnce(googleObject,eventName,function(event){element.triggerHandler('map-once-'+eventName,event);//We create an $apply if it isn't happening. we need better support for this//We don't want to use timeout because tons of these events fire at once,//and we only need one $applyif(!scope.$$phase)scope.$apply();});});}
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I need to do geocoding on a map object, and as best I could see, there is no support for "addListenerOnce" and/or the tilesloaded event.
It was trivial to add it. And yes, I know this is NOT elegant. :)
In the controller:
Not a show stopper, just an FYI.
The text was updated successfully, but these errors were encountered: