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

Can I get the original position of a marker? #26

Open
t2oh4e opened this issue Jan 16, 2013 · 5 comments
Open

Can I get the original position of a marker? #26

t2oh4e opened this issue Jan 16, 2013 · 5 comments

Comments

@t2oh4e
Copy link

t2oh4e commented Jan 16, 2013

I implemented the plugin in a project and it works really fine.
But there is one thing I really miss: I use the markers position to calculate the distance between my location and the marker. When a marker is spiderfied it changes its position. Due to this my calculations are not correct. In most cases it's just a few meters, but sometimes several hundred meter if I have a large amount of markers and therefor a big spiral.

Long story short: Is there any way to get the markers original position without unspiderfying them?

@jawj
Copy link
Owner

jawj commented Jan 16, 2013

Yes, it's undocumented (and theoretically subject to change), but you can see an example of this in the markersNearMarker method, on line 170 of the CoffeeScript source.

A spiderfied marker has an _omsData property, and this has a usualPosition property.

So in CoffeeScript, you can get the original position as follows:

position = marker._omsData?.usualPosition ? marker.position

And in plain JS it's:

position = marker._omsData ? marker._omsData.usualPosition : marker.position;

@jawj jawj closed this as completed Jan 16, 2013
@t2oh4e
Copy link
Author

t2oh4e commented Jan 16, 2013

Well, that was fast. Thanks a lot!

@phtrivier
Copy link

Sorry to reopen, but the "usualPosition" does not seem to be available when using the javascript, compiled version of the script. The property is called mkr._omsData.l - I supposed it's the compiler that rename it since it is not exposed... would probably be a good idea to expose it (and document it ;) )

@jawj
Copy link
Owner

jawj commented Aug 8, 2013

Yes, I guess you're right on both counts. I'll reopen this as an enhancement, but it may be a little while before I get round to it.

@jawj jawj reopened this Aug 8, 2013
@tverilytt
Copy link

First of all - thanks a bunch for a great utility :-)
It really is most helpful in a Google Maps mashup application I made, where potentially a lot or markers migt be on the same / near position. E.g. markers for Instagrams, Eventfuls etc. (one can check it out here: http://jo2maps.mybluemix.net/map).

I also stumbled upon this theme on markers original position vs. spiderfied position.
I realised in in connection with using Google maps direction service to get walking directions between two markers.
For now I will use the undocumented _omsData.l property instead of adding my own property.

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

4 participants