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

SlidingMarker doesn't define MAX_ZINDEX #18

Open
GehDoc opened this issue May 1, 2017 · 4 comments
Open

SlidingMarker doesn't define MAX_ZINDEX #18

GehDoc opened this issue May 1, 2017 · 4 comments
Labels

Comments

@GehDoc
Copy link

GehDoc commented May 1, 2017

SlidingMarker doesn't define this property.

Replacing Google Marker globally by using SlidingMarker.initializeGlobally, breaks some code. For exemple, the last version of OverlappingMarkerSpiderfier library.

@viskin
Copy link
Member

viskin commented May 2, 2017

Ok, let's think how to resolve this issue.
MAX_ZINDEX is not a property on a marker, but instead a constant on google.maps.Marker, so you can access its value like this:

google.maps.Marker.MAX_ZINDEX

Now, please provide your code that causes the problem.

@GehDoc
Copy link
Author

GehDoc commented May 2, 2017

That's exactly my problem.
After a call to SlidingMarker.initializeGlobally(), I can no more use this value :

		// Replace standard markers
		console.log(google.maps.Marker.MAX_ZINDEX); // 1000000
		SlidingMarker.initializeGlobally();
		console.log(google.maps.Marker.MAX_ZINDEX); // undefined -> problem

		map = new google.maps.Map(document.getElementById('map_canvas'), {
			zoom: 12,
			mapTypeId: google.maps.MapTypeId.HYBRID
		});

		// last version 2017/05/02 : https://github.com/jawj/OverlappingMarkerSpiderfier. Not the version you provide (I haven't tested it).
		// broken because it needs google.maps.Marker.MAX_ZINDEX to promote spiderfied markers : they stay at their initial z-index.
		var oms = new OverlappingMarkerSpiderfier(
			map,
			{ 
				markersWontMove: true,
				markersWontHide: true,
				basicFormatEvents: true,
				keepSpiderfied: true,
				circleFootSeparation: 23*1.5,	// default = 23
				spiralLengthStart: 11*1.5,		// default = 11
				nearbyDistance: 20*1.5,			// default = 20
			}
		);

A quick fix which works for me, is to add this code at the end of decorates function of slidingmarker.js file :

        var decorates = function (childCtor, parentCtor) {
            // [...]
            childCtor.MAX_ZINDEX = GoogleMarker.MAX_ZINDEX; // quick and dirty fix
        };

That's certainly not the right way. And other properties may be missing, but I'm not affected.

@GehDoc
Copy link
Author

GehDoc commented May 4, 2017

An external solution (without modifying your library) is simpler, directly in my code :

		var MAX_ZINDEX = google.maps.Marker.MAX_ZINDEX;
		SlidingMarker.initializeGlobally();
		google.maps.Marker.MAX_ZINDEX = MAX_ZINDEX;

@viskin
Copy link
Member

viskin commented May 7, 2017

Oh, sure this is a bug. I will try to fix it ASAP.
Thank you.

@viskin viskin added the bug label May 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants