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

Map won't center correctly when using spiderfier #150

Closed
resqonline opened this issue May 22, 2018 · 4 comments
Closed

Map won't center correctly when using spiderfier #150

resqonline opened this issue May 22, 2018 · 4 comments

Comments

@resqonline
Copy link

I am having trouble with the spiderfier - as soon as I activate it, the map won't center and fit to the bounds, instead it just shows somewhere around the equator (the blackened part is where my json file does an overlay)

screenshot 2018-05-22 10 10 05

I am not getting any errors in the console, though.
As soon as I deactivate the spiderfying, the whole map shows up correctly. But I need a solution to show overlapping markers (sometimes there are five or more in the same spot). I am using Advanced Custom Fields plugin in WordPress to manage the markers with the Google Maps field and included the Spiderfier function like this:

    // Spiderfier
    var oms = new OverlappingMarkerSpiderfier(map, { markersWontMove: true, markersWontHide: true, keepSpiderfied: true, legWeight: 2, circleFootSeparation: 50});

    function omsMarkers( markers ) {
      for ( var i = 0; i < markers.length; i++ ) {
        oms.addMarker( markers[i] );
      }
    }

    omsMarkers(markers);

You can take a look at the whole skript here: https://github.com/resqonline/code-snippets/blob/master/google-maps.js

@jawj
Copy link
Owner

jawj commented May 22, 2018

Looking at the whole script, the markers variable appears to be set to []? Do you need to use $markers instead (and is this an array of Google Maps Marker objects, as it will need to be)?

@resqonline
Copy link
Author

yes it is an array of marker objects

@resqonline
Copy link
Author

@jawj just noticed that the error only occurs on start page with the map, it seems on sub-pages (taxonomies and such) everything is fine. I am using the same template tag on all pages including start page, so I am not sure, why it throws an error on the front page but not on other pages.

@resqonline
Copy link
Author

@jawj finally found the issue! it seems it mattered, how and when the individual functions were called... good heavens, this is why I don't like JS 😄

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

No branches or pull requests

2 participants