Open ProLoser opened 11 years ago
Do you need to watch the array of markers for changes for this? If so, there is code in ui-calendar that watches arrays and calls onAdded/onChanged/onRemoved
Right now you have to call new google.maps.marker({ map: mapObject, ...})
etc
I feel this should not be necessary.
Right. So you watch the array of user-supplied marker, and:
onAdded(marker): new google.maps.marker onRemoved(marker): delete marker onChanged(marker): update marker position and other attributes
The code that can efficiently watch for array changes and emit those events is in the changeWatcher
in ui-calendar
. If I understand correctly, and that code would be perfect for these needs, maybe we should extract it into a service and move it to ui-utils
The direction of ui-map is that it doesn't try to take away google's Apis from you: that is too much work. There are a billion ways you could want to create and initialize a marker. The directives just $apply events for you and make them declarative.
Andy Joslin from my mobile
On Thu, May 16, 2013 at 10:11 AM, Gleb Mazovetskiy notifications@github.com wrote:
Right. So you watch the array of user-supplied marker, and: onAdded(marker): new google.maps.marker onRemoved(marker): delete marker onChanged(marker): update marker position and other attributes
The code that can efficiently watch for array changes and emit those events is in the
changeWatcher
inui-calendar
. If I understand correctly, and that code would be perfect for these needs, maybe we should extract it into a service and move it toui-utils
Reply to this email directly or view it on GitHub: https://github.com/angular-ui/ui-map/issues/8#issuecomment-18003369
This doesn't take away the ability use native marker api if you want to. Why not offer both options? Simple common use case, and advanced use still possible.
@ajoslin Yeah after my friend got it working I was less concerned with hand-holding the tag creation for you as I realize there are a lot of open questions it raises. I still think it would be nice to try dabbling with however in a simplistic manner (you pass the entire object to the child tag as an attribute, and the linking takes care of the timing, instead of $scope.$watch('map')
)
For now though I think it's more important to clean up the docs and provide an example of loading the map with markers pre-populated.
Yeah, if there is a better way, definitely do it!!
By the way, looks like this implementation does automatic marker binding https://github.com/dylanfprice/angular-gm/blob/master/src/directives/gmMarkers.js
Kind of annoying if I want to put a few markers onto the page. I think it would be more sensible to do something like this:
The 'map' property would be added automatically to the object, and new markers would be generated for you.