Open sabun123 opened 7 years ago
Ok, I seem to have found a working solution. Initialize OMS in Google Map's IDLE event. This seems to be the exact time Google Map's first registers that it's fully loaded and ready to go (as far as Google can tell me).
Solution:
var doOnce = true;
function initOMS(){
// Initializing OMS
oms = new window.OverlappingMarkerSpiderfier(map, {
markersWontMove: true,
keepSpiderfied: true,
nearbyDistance: 10,
circleFootSeparation: 60,
legWeight: 1.5
});
}
window.google.maps.event.addListener(map, "idle",()=>{
// Do Once. Init OMS library
if(doOnce){
initOMS();
doOnce = false;
}
});
Hopefully this helps anyone else who attempts to Google this problem similar to mine. To the developers, if there is a better way, I'm all ears! I appreciate the library, it's very cool.
I get "OverlappingMarkerSpiderfier is not a constructor" with my Google Maps web application. When this happens, naturally everything and anything after this is royally screwed up and ceases functioning on the page.
At first I was initializing OMS at the end after the map init, after having set all events. From a quick Google, the rule of thumb seems to be that Google Maps must be fully loaded before initializing or using OMS. So I tried the following.
What I've tried:
// Initialize OMS after the Window is fully loaded window.onload = initOMS();