Skip to content
This repository has been archived by the owner on May 25, 2019. It is now read-only.

ui-map-marker should create a marker FOR you, instead of merely attach to an existing one. #8

Open
ProLoser opened this issue May 15, 2013 · 8 comments

Comments

@ProLoser
Copy link
Member

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:

<div ui-map>
  <div ng-repeat="marker in markers" ui-map-marker="marker">Popup Html Goes Here</div>
</div>
$scope.markers = [ { position: 11 }, { position: 12 } ];

The 'map' property would be added automatically to the object, and new markers would be generated for you.

@glebm
Copy link
Contributor

glebm commented May 16, 2013

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

@ProLoser
Copy link
Member Author

Right now you have to call new google.maps.marker({ map: mapObject, ...}) etc

I feel this should not be necessary.

@glebm
Copy link
Contributor

glebm commented May 16, 2013

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

@ajoslin
Copy link
Contributor

ajoslin commented May 16, 2013

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
[email protected] 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 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

Reply to this email directly or view it on GitHub:
#8 (comment)

@glebm
Copy link
Contributor

glebm commented May 16, 2013

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.

@ProLoser
Copy link
Member Author

@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.

@ajoslin
Copy link
Contributor

ajoslin commented May 16, 2013

Yeah, if there is a better way, definitely do it!!

@glebm
Copy link
Contributor

glebm commented May 19, 2013

By the way, looks like this implementation does automatic marker binding https://github.com/dylanfprice/angular-gm/blob/master/src/directives/gmMarkers.js

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants