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

Performance of addMarker() #175

Open
bavarianbytes opened this issue Feb 23, 2022 · 0 comments
Open

Performance of addMarker() #175

bavarianbytes opened this issue Feb 23, 2022 · 0 comments

Comments

@bavarianbytes
Copy link

When i add 2k or more markers to the map via OMS, the method addMarker() need seconds and freezes the browser UI. If i add them directly to the map, that doesn't happen.
Any ideas to make that more performant?

// jobMarkers.length = 2k

for(var i = 0; i < jobMarkers.length; i++) {
    // create marker out of job
    var marker = new google.maps.Marker({
        icon: {
            url: createMarkerInlineSVG(page.maps.marker.color),
            scaledSize: new google.maps.Size(mapsMarkerWidth, mapsMarkerHeight),
        },
        position: {
            lat: jobMarkers[i].lat,
            lng: jobMarkers[i].lng
        },
        title: jobMarkers[i].title,
        city: jobMarkers[i].city,
        state: jobMarkers[i].state,
        country: jobMarkers[i].country,
        organization: jobMarkers[i].organization,
        slug: jobMarkers[i].slug
    });

    // open info window on click
    google.maps.event.addListener(marker, 'spider_click', function() {
        markerWindow.setContent(createMarkerWindowContent(this));
        markerWindow.open(map, marker);
    });

    // add to spiderfier and cluster
    markerSpiderfier.addMarker(marker);
    markerCluster.addMarker(marker);
}
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

1 participant