dylanfprice / angular-gm

AngularJS Google Maps Directives
MIT License
197 stars 47 forks source link

Problem using MapClusterer #24

Closed mukgupta closed 10 years ago

mukgupta commented 11 years ago

I want to use Google Mapsclusterer for the markers. For that i need to get the marker and map instance. I can get the map instance from the getPromise but i cannot get marker instance.

wpalahnuk commented 11 years ago

I had a similar issue, I can upload the solution I used tomorrow or the next day

mukgupta commented 11 years ago

@wpalahnuk : can you please share.

wpalahnuk commented 11 years ago

Here's my quick solution,

https://github.com/wpalahnuk/angular-gm

I've added in a getMarker(mapId) function to the container which returns the markers for the provided mapId. It's not fully tested yet because I've got a bunch of other changes I'm going to make, but it should work for now.

JohnLindahlTech commented 10 years ago

@wpalahnuk is there any gist/plunkr to show how to use your fork with MapClusterer?

wpalahnuk commented 10 years ago

@JohnPhoto all you have to do is call the markerclusterer constructor after the markers have been updated by the angular-gm controller.

var markers = angulargmContainer.getMarkers(mapId)
var map = angulargmContainer.getMap(mapId);
var markerCluster = new MarkerClusterer(map, markers);

It's a pretty crappy way to do it but it works for now. dylanfprice is currently making some changes to angular-gm but once he's done I'm going to put out a directive that allows you to use markercluster with angular-gm. Probably one for Overlapping Marker Spiderfier as well

JohnLindahlTech commented 10 years ago

Thank you for the update, will follow this like a hawk since this is something I really need for my project.

dylanfprice commented 10 years ago

I don't have time to look into this but it should be possible to create a directive that does this by taking advantage of the angulargmMapController#forEachElementInScope function. I can imagine something along the lines of:

<gm-map ...>
  <gm-markers ... gm-markerclusterer></gm-markers>
</gm-map>

I'm going to go ahead and close this but if you do end up making the directive I'd love to get a PR for it!

marjoripomarole commented 10 years ago

Would love a directive with Overlapping Marker Spiderfier! :+1:

teone commented 10 years ago

@JohnPhoto Would love to have a Cluster sample too! Have you find out something?

JohnLindahlTech commented 10 years ago

No sorry I have not found out how to do this. It was not really prioritized in my project after all.

lucasloliveira commented 10 years ago

That would help me as well... I've tried a few approaches but none worked yet.