Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlapping Marker Spiderfier #1146

Closed
Chris-Devine opened this issue Sep 12, 2017 · 23 comments
Closed

Overlapping Marker Spiderfier #1146

Chris-Devine opened this issue Sep 12, 2017 · 23 comments

Comments

@Chris-Devine
Copy link

Issue description
Currently when two or more markers overlap or directly on top of one another there is no way to click/select the bottom marker.

Steps to reproduce and a minimal demo of the problem
Add two markers using the same lat,long and try show the info window for both.

as seen in below plunkr

http://plnkr.co/edit/031xGrYzAVfYR3k1OyYg?p=info

Current behavior
Cannot click the behind marker

Expected/desired behavior
Unlike the google API, in actual google maps, if this occurs, then when the user hovers over the marker the other markers will expand out in a circular pattern to allow the user to select which pin the would like to select.

This behavouir has been replicated in the package below:
https://github.com/jawj/OverlappingMarkerSpiderfier

I was wondering if this type of feature could implemented into this package or if its already on the developers roadmap?

@sebholstein
Copy link
Owner

That would definitely be a nice feature but would be in a seperate @ agm NPM Package (so not in the agm/core package). That would be a perfect fit for a little community project for agm. Or someone has time to implement it here.

@aaahti
Copy link

aaahti commented Sep 21, 2017

Would love to have that feature

@Badmonky
Copy link

Badmonky commented Nov 3, 2017

We have a related issue in our project right now i think. We use clusters on agm. and if we have two markers with the exact same address (e.g. two businesses in the same building) the cluster cannot be opened. if we click on it, it just disappears into nirvana. Whats your opinion on that @SebastianM. Is this the same issue?

@Luis16287
Copy link

Same issue of @Badmonky

@Chris-Devine
Copy link
Author

I found a work around for this, you can set "maxZoom" property so that when your fully zoomed in you do not cluster anymore.

This will fix markers that are very close, but will not fix the issue of 2 markers in the same position, the Spiderfier extension would still be need to fix this issue.

@tomasprieboj
Copy link

Is there any way how to list all markers on cluster click?

@Badmonky
Copy link

Hi there again. Did anyone look into the "same address" issue yet? Our production system has that issue right now, and its a huge problem.

@Badmonky
Copy link

@SebastianM any news on this?

@Tomdrouv1
Copy link

Tomdrouv1 commented Feb 12, 2018

Hi! @SebastianM any news on this feature ?

@chancezeus
Copy link

chancezeus commented Feb 23, 2018

I was giving it a try to make a module for this, but ran into the following:

The way the "MarkerManager" -> "ClusterManager" relation is set up, it seems/is impossible to have a "SpiderManager" that can be nested within the "ClusterManager" or vice-versa.

So something like:

<agm-map>
    <agm-marker-cluster>
        <agm-marker-spider>
            <agm-marker>
            <agm-marker>
            ....
        </agm-marker-spider>
    </agm-marker-cluster>
</agm-map>

This makes it impossible to create a map view where up until "maxZoom" of the clusterer you get nice "clustered" markers and after that the spiderfier kicks in to be able to "(un)spiderfy" the marker.

I know you could use @Host combined with @Optional to reference the ClusterManager but in that case a situation like the following

<agm-map>
    <agm-marker-cluster>
        <agm-marker>
        <agm-marker>
        ....
    </agm-marker-cluster>
    <agm-marker-spider>
        <agm-marker>
        <agm-marker>
        ....
    </agm-marker-spider>
</agm-map>

will also resolve the ClusterManager and thus add the markers (incorrectly) to the cluster too.

Maybe someone can correct me if I see this wrong or has a suggestion on how to do this using the current implementation, since otherwise it might mean a major (potentially breaking) change to the @agm/core and @agm/js-marker-clusterer packages.

Some changes still will be required, but these will be minor (adding a addNativeMarker/deleteNativeMarker so the nested * extends MarkerManager can forward it's addMarker/deleteMarker onto the parent without creating a completely new marker instance (which also defeats the purpose of nesting them 😉))

@chancezeus
Copy link

chancezeus commented Feb 24, 2018

I made some changes to the existing core and cluster packages and added a package for OverlappingMarkerSpiderfier support, initial testing shows it works as expected (also when used in a "nested" setup with the clusterer) so please test/review and we can also add the spiderfier as part of this libraries supported options.

@ChrisDevinePimss
Copy link

@chancezeus Thats great news, id like to test it, any examples on how to use it?

@jonomacd
Copy link

Thanks for working on this! I am also very interested in using it. If you have some brief instructions on how to set it up that would be great!

<agm-map style="width:100%; height:400px;" [latitude]="lat" [longitude]="lng" [zoom]="12">
    <agm-marker-cluster  [maxZoom]="15" [imagePath]="'https://googlemaps.github.io/js-marker-clusterer/images/m'">
         <agm-marker *ngFor='let carer of family.carers' [latitude]="carer.latitude" [longitude]="carer.longitude">                    
        </agm-marker>
    </agm-marker-cluster>
</agm-map>   

I presume I can just install spiderfier and change my agm-marker-cluster to agm-marker-spiderfier. I'm just unsure how to install it...

@cinilak
Copy link

cinilak commented Mar 22, 2018

@chancezeus I would also appreciate if you could share a guide on how to implement this, thanks :)

zolastro added a commit to TopicFriends/TopicFriends that referenced this issue Mar 28, 2018
Used some trigonometry to add a circular offset around the center. The
offset depends in the amount of topics that are displayed. I've also
consider storing the offsets OnInit so we don't have to calculate them
for each user/topics. I would like to change this in the future and use
the new spiderfier of GoogleMapsAPI v3 (currently on develop in angular-
google-maps)

Related links:
https://github.com/jawj/OverlappingMarkerSpiderfier
sebholstein/angular-google-maps#1146

Closes #76
@Luis16287
Copy link

@jonomacd Could you please explain to me how you made it work? I presume I can just install spiderfier and change my agm-marker-cluster to agm-marker-spiderfier. I'm just unsure how to install it...
Only agm-marker-cluster works, I can not see results for agm-marker-spiderfier.
I would appreciate your help.

@stale
Copy link

stale bot commented Nov 19, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 19, 2018
@stale stale bot closed this as completed Nov 26, 2018
@MattStrybis
Copy link

Any feedback on the above? See its become pretty stale.

@hernantomassini
Copy link

@MattStrybis look this #1329

@MattStrybis
Copy link

@MattStrybis look this #1329

Thanks @hernantomassini perfect!!

@ghost ghost reopened this Aug 9, 2019
@stale stale bot removed the stale label Aug 9, 2019
@henryyue2010
Copy link

I met problems when trying to use agm-oms with js-marker-clusterer. Hopfully, the package of marker spiderfier can be fully supported in agm asap. Thank you very much.

@jason2211
Copy link

@henryyue2010 have you tried the npm package agm-spiderfeir? It is a fork of agm-oms that fixes an issue. It is working for me with js-marker-clusterer and ts-overlapping-marker-spiderfier.

@ghost
Copy link

ghost commented Nov 12, 2019

Closed, as we don't support spidifier.

@ghost ghost closed this as completed Nov 12, 2019
@ZenSide
Copy link

ZenSide commented Nov 14, 2019

For people wanted to use both spiderfier and cluster plugins, my solution is to separate them with marker replication and adding a ngIf condition based on current zoom (as they don't work on same zoom level)

<agm-map (zoomChange)="currentZoom = $event" [zoom]="currentZoom">
    <agm-marker-cluster *ngIf="gpsZoom<=12">
         <agm-marker *ngFor="let marker of markers">
             ...
         </agm-marker>
    </agm-marker-cluster>
    <agm-marker-spider *ngIf="gpsZoom>12">
        <agm-marker *ngFor="let marker of markers">
            ...
        </agm-marker>
    </agm-marker-spider>
</agm-map>

(related to this stack overflow question

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests