| Author |
Markers at same location |
martin
Super Administrator
Posts: 224
Location: Norfolk, UK.
Joined: 24.07.08 |
| Posted on 23-02-2009 10:05 |
|
|
Hi all.
I've been working on a new way to handle markers which are at the same location on a map.
That is markers that don't uncluster no matter how much the map is zoomed in.
The result can be seen here: ClusterMarker: newClusterMarkerClick method.
Click a cluster marker and an infowindow opens on that cluster marker.
The infowindow contains a link to each clustered marker within that cluster.
Click a link to a clustered marker and the cluster marker hides itself and the marker linked to is shown along with it's infowindow.
Close that infowindow and the cluster marker re-appears and the clustered marker disappears.
The demo map might look a bit ugly when there are many markers within a cluster - the infowindow will try to size itself to contain all the links and grow quite tall.
This is new code that has not been fully tested yet.
If a clustered marker and infowindow is shown and then another (different) cluster marker is clicked the results are unpredictable.
I'll be working on this over the next few days and keep this thread updated.
For anyone that wants to try the new code you will have to look at the demo map source code and the modified ClusterMarker.js file.
The new code in the map source should be pretty straightforward to follow.
And all modifications in ClusterMarker.js are commented - comments starting with // modification:.
I'll work on this new method over the next few days and hopefully iron out any bugs as i find them.
Martin. |
|
| Author |
RE: Markers at same location |
martin
Super Administrator
Posts: 224
Location: Norfolk, UK.
Joined: 24.07.08 |
| Posted on 23-02-2009 13:00 |
|
|
Small update to report...
I've fixed the bug i referred to - a little problem with function closure i think.
I've uploaded the new map.
Now i'm using DOM method document.createElement() to create a cluster marker's infowindow list of clustered markers.
It needs a little bit of CSS style to improve the appearance but the new code now seems to function perfectly(!).
Clicking an infowindow with many clustered markers will open an infowindow that's way too tall to fit on the map and it's contents will overflow the infowindow for example.
If anyone gives the Demo Map a look and finds any errors or strange behaviour then please post in this thread.
Thanks.
Martin. |
|
| Author |
RE: Markers at same location |
katutxakur
Member
Posts: 4
Joined: 22.02.09 |
| Posted on 27-02-2009 10:53 |
|
|
Hi Martin,
I found a bug in your map, when I click a cluster marker and then I click the link to a clustered marker, it appears an infowindow of that clustered marker. Well, while that infowindow is still there, if I start zooming out (for example), the map won't cluster any marker because the refresh is disabled.
I don't know if I could explain it clearly and i'm a newbie in javascript so maybe it's a known issue.
Edited by katutxakur on 27-02-2009 10:59 |
|
|
| Author |
RE: Markers at same location |
martin
Super Administrator
Posts: 224
Location: Norfolk, UK.
Joined: 24.07.08 |
| Posted on 02-03-2009 08:17 |
|
|
Hi again.
That's not so much a bug as a quick workaround to another problem.
Take a cluster marker and click it and you get an infowindow of links to the markers within that cluster.
Zoom in or out until the clustering would change - refresh() would be enabled.
If refresh() is enabled then the links within the infowindow would now be invalid and cause errors if clicked.
Closing and then reopening a new infowindow is a possible solution but not very elegant.
So i'm looking for another way to implement the new cluster marker click behaviour.
I'm playing with a new triggerClick() method that may do the job.
But still there are practical issues to tackle.
If a cluster marker is hidden and a previously clustered marker shown then ClusterMarker should continue to refresh() upon map zoom and panning.
How will ClusterMarker handle a new cluster where one of the to be clustered markers is visible?
The existing ClusterMarker methods weren't written to handle such events and i think it's time for me to take a look at rewriting ClusterMarker.
I have no idea how long it will take or when i will have time but hope that i can get some working code online within the next week or so.
Martin. |
|
| Author |
RE: Markers at same location |
Mad_Matt
Member
Posts: 1
Joined: 09.06.10 |
| Posted on 10-06-2010 12:45 |
|
|
I've just tested this and it seems to work well (given the issues mentioned above). Any progress on this, or is there something I can do to help?
Cheers,
Matt. |
|
|
| Author |
RE: Markers at same location |
martin
Super Administrator
Posts: 224
Location: Norfolk, UK.
Joined: 24.07.08 |
| Posted on 11-06-2010 06:14 |
|
|
Hi and welcome to the forum.
I decided that version 1.3.2 of ClusterMarker could not effectively be updated to handle situations such as markers that would not uncluster at a map's maximum zoom level.
The newer but as yet unreleased version 2 of ClusterMarker handles such clusters much more effectively.
Take a look at this map: http://developer.martinpearman.co.uk/phpfusion7/infusions/google_my_maps/google_my_maps.php?map_id=6.
The sidebar links Exact location#? and Nearby #? will display a clustered marker and disable the cluster that the marker belongs to as long as the marker's infowindow is open.
The map that i recently developed here: http://planefinder.net/ uses the newer version 2 of ClusterMarker, a click on a cluster marker (grey plane icon) open an infowindow with three options; Show links, Fit map to markers and Zoom in.
The Show links option displays a list of links to each marker in that cluster and a click on a link zooms the map in to uncluster the marker.
There are no planes at exactly the same location so the original issue is not possible with the Planefinder map.
So version 2 has two methods to uncluster a marker; zoom in until the marker is unclustered (the method of version 1.3.2) or a marker in a cluster can be displayed and the cluster not displayed.
Version 2 of ClusterMarker is more efficient in the way it creates cluster markers too, if a cluster remains unchanged after a pan or zoom of the map then it is no longer removed from the map and recreated. Along with some other code improvements i hope version 2 will perform better than version 1.3.2 and better handle large datasets.
I've used ClusterMarker in a few projects this year and had to modify it somewhat for each map, there's still an ongoing problem with scope where an instance of ClusterMarker needs to access the parent page but this can probably be overcome with a new custom event.
With version 2 of the Google Maps API now deprecated i don't anticipate there being any newer version of ClusterMarker than the unreleased version 2.
I'd like to find time to truly complete it and document it and create some new demo maps to show off it's features but am just too busy with paid for work.
So i'd suggest you grab a copy of ClusterMarker version 2 from the above link to the PhpFusion map and give it a try.
Start a new thread if or when you run into problems and i'll help you out.
Version 2 has a new property in it's addMarkers() method, $areOverlaid is the property name in the code, and this doesn't always function as desired.
I think this is where i have introduced code to handle GMarker show() and hide() methods and the logic breaks down.
Also the removeMarkers() method is incomplete on the PhpFusion version of ClusterMarker, on the Planefinder.net map i have written a working removeMarkers() method but this is more of a fix for the PlaneFinder.net map rather than a new method to use in the unmodified version 2 of ClusterMarker.
Other than that you shouldn't have any problems getting it working!
Martin. |
|