angular-ui / angular-google-maps

AngularJS directives for the Google Maps Javascript API
http://angular-ui.github.io/angular-google-maps
2.52k stars 1.07k forks source link

ui-gmap-markers options can't not use current model #1609

Open tianxu0836 opened 8 years ago

tianxu0836 commented 8 years ago

I'm trying to load icon for each mark. each mark's icon is different.

I have a function "getIcon", it will needs the uid from each binding model(item.Uid).

If I pass "this" to getIcon, it is undefined.

It seems like there is no way to find the current model.

I will have to use "ui-gmap-markers" here not "ui-gmap-marker"

This options works really weird.

<ui-gmap-markers models="items" idkey="'Uid'"                     
                 options="{icon: getIcon(this, map.zoom)}"
                 coords="'self'" icon="'icon'">
</ui-gmap-markers>
nmccready commented 8 years ago

Look at the documentation on getPlurals

nmccready commented 8 years ago

and control

tianxu0836 commented 8 years ago

I don't see any example about how to use this control thing and getPlurals. by the way, I think it doesn't support multiple ui-gmap-markers tags in one map really well, so I assugme I can only assign one markerControl to one ui-gmap-markers. what if I have multiple ui-gmap-markers with different clusters? it seems like no way to solve it? How can I use one logic for dynamic updated the options for each marker in each ui-gmap-markers depending on each marks' id?

nmccready commented 8 years ago

Can you make an example on the problem your trying to solve. Then I may be able to better assist you. If you have multiple ui-gmap-markers you are right they are all unique sets. So that is your issue to deal with.

tianxu0836 commented 8 years ago

Here is what I'm doing:

<ui-gmap-markers models="group.items" ng-repeat="group in Groups" idkey="'Uid'"                     
                 options="{icon: getIcon(thisModel, map.zoom)}" type="'cluster'"
typeoptions='{"title":group.Name, gridSize: 175,"ignoreHidden":true,averageCenter: true,"minimumClusterSize":getMinimumClusterSize(group.items), styles: getClusterStyle(group)}'
                 coords="'self'" icon="'icon'">
</ui-gmap-markers>

each item in each group has a Uid. I need to show the marker icon based on the Uid. each mark have its own icon.

I need to have one cluster per group. cluster minimum size depends on how many visible items in each group.

I will also need to manually calculate the marker icon size based on the zoom level.

nmccready commented 8 years ago

options="{icon: getIcon(thisModel, map.zoom)}" not sure if that part will work. But you should be able to do options="getOptions".

##controller
getOptions: (model) ->
  #do stuff with your model and derive options with map.zoom and etc..
nmccready commented 8 years ago

Still would be easier for me to tinker in a plnkr that you setup.

tianxu0836 commented 8 years ago

Yes, options="getOptions" works for me, but if what if I need to calculate and update the options while I'm zooming?

nmccready commented 8 years ago

Then track zoom with watches and or google map events. Modify the options there and it should trigger a digest, which will call getOptions again.

nmccready commented 8 years ago

As for your clustering problems; you will need to dive into the clustering code and look at calculate.