Google Maps API Projects
Home · Demo Maps · Projects · Discussion Forums · Downloads · Developer Available · Google Search · Site SearchSeptember 07 2010 09:23
Navigation
Home
Demo Maps
Projects
Discussion Forums
Downloads
Useful Links
Developer Available
Contact Me
Privacy Policy
Search
Google Search
Site Search
Paypal Donate

Donations encourage developers such as myself to provide support for and develop new versions of our code.

View Thread
Google Maps API Projects | ClusterMarker | General discussion
Author InfoWindow Markers
clavero
Member

Posts: 4
Joined: 06.05.10
Posted on 06-05-2010 13:53
Hello,
I state that I am not a clever programmer and I hope to get some help from you.
I am building a map with many departments and ClusterMarker is exactly what I need to have an ordered map. I should make some changes to the example:


http://googlemapsapi.martinpearman.co.uk/infusions/google_maps_api/google_maps_api.php?map_id=4

Pratically, once I click on a marker, I would insert in the white box a description of the department with all the informations about it, as in the example in Fig.



--->



I have no problems for a description in html in the box, I just need to understand how to insert it using your example.

Thanking you from now,
Claudio
Author RE: InfoWindow Markers
martin
Super Administrator

Posts: 224
Location: Norfolk, UK.
Joined: 24.07.08
Posted on 07-05-2010 04:54
Hi Claudio and welcome to the forum.

Have you got an existing working map - without ClusterMarker - that i can take a look at?

It's likely to be easier to add ClusterMarker to an existing working map than it would be to take the Demo Map example and change it to suit your needs.

If you have a map and can post the URL then please do - and if you'd rather not post the URL in the forum then just PM me the URL and i'll take a look.

Thanks.

Martin.
http://martinpearman.co.uk
Author RE: InfoWindow Markers
clavero
Member

Posts: 4
Joined: 06.05.10
Posted on 07-05-2010 16:06
martin wrote:
Hi Claudio and welcome to the forum.

Have you got an existing working map - without ClusterMarker - that i can take a look at?

It's likely to be easier to add ClusterMarker to an existing working map than it would be to take the Demo Map example and change it to suit your needs.

If you have a map and can post the URL then please do - and if you'd rather not post the URL in the forum then just PM me the URL and i'll take a look.

Thanks.

Martin.


Hello Martin,
now, I have solved this problem, but now I have another one.
I have modified the example http://googlemapsapi.martinpearman.co.uk/infusions/google_maps_api/basic_page.php?map_id=4

adding the function (myClusterClick) located in :

http://googlemapsapi.martinpearman.co.uk/infusions/google_maps_api/basic_page.php?map_id=5:
---------------------------

function myClusterClick(args) {
cluster.defaultClickAction=function(){
map.setCenter(args.clusterMarker.getLatLng(), map.getBoundsZoomLevel(args.clusterMarker.clusterGroupBounds))
delete cluster.defaultClickAction;
}
var html='<div style="height:8em; overflow:auto; width:24em"><h4>'+args.clusteredMarkers.length+' Locations:</h4>';
for (i=0; i<args.clusteredMarkers.length; i++) {
html+='<a href="javascript:cluster.triggerClick('+args.clusteredMarkers[i].index+'smiley">'+args.clusteredMarkers[i].getTitle()+'</a><br />';
}
html+='<br /><a href="javascript:void(0)" onclick="cluster.defaultClickAction()">Zoom</a> in to show these locations</div>';
// args.clusterMarker.openInfoWindowHtml(html);
map.openInfoWindowHtml(args.clusterMarker.getLatLng(), html);
}

// create a ClusterMarker
cluster=new ClusterMarker(map, {markers:markersArray, clusterMarkerTitle:'Click to see info about %count locations' , clusterMarkerClick:myClusterClick });
cluster.fitMapToMarkers();




----------------------

the problem is that when I click on "Zoom in to show These locations", the balloon remains, as shown:


When I click "Zoom" in to show These locations" happens this:


It may depend of what?

Thanks again for your availability,
Claudio
Author RE: InfoWindow Markers
clavero
Member

Posts: 4
Joined: 06.05.10
Posted on 08-05-2010 14:58
clavero wrote:
martin wrote:
Hi Claudio and welcome to the forum.

Have you got an existing working map - without ClusterMarker - that i can take a look at?

It's likely to be easier to add ClusterMarker to an existing working map than it would be to take the Demo Map example and change it to suit your needs.

If you have a map and can post the URL then please do - and if you'd rather not post the URL in the forum then just PM me the URL and i'll take a look.

Thanks.

Martin.


Hello Martin,
now, I have solved this problem, but now I have another one.
I have modified the example http://googlemapsapi.martinpearman.co.uk/infusions/google_maps_api/basic_page.php?map_id=4

adding the function (myClusterClick) located in :

http://googlemapsapi.martinpearman.co.uk/infusions/google_maps_api/basic_page.php?map_id=5:
---------------------------

function myClusterClick(args) {
cluster.defaultClickAction=function(){
map.setCenter(args.clusterMarker.getLatLng(), map.getBoundsZoomLevel(args.clusterMarker.clusterGroupBounds))
delete cluster.defaultClickAction;
}
var html='<div style="height:8em; overflow:auto; width:24em"><h4>'+args.clusteredMarkers.length+' Locations:</h4>';
for (i=0; i<args.clusteredMarkers.length; i++) {
html+='<a href="javascript:cluster.triggerClick('+args.clusteredMarkers[i].index+'smiley">'+args.clusteredMarkers[i].getTitle()+'</a><br />';
}
html+='<br /><a href="javascript:void(0)" onclick="cluster.defaultClickAction()">Zoom</a> in to show these locations</div>';
// args.clusterMarker.openInfoWindowHtml(html);
map.openInfoWindowHtml(args.clusterMarker.getLatLng(), html);
}

// create a ClusterMarker
cluster=new ClusterMarker(map, {markers:markersArray, clusterMarkerTitle:'Click to see info about %count locations' , clusterMarkerClick:myClusterClick });
cluster.fitMapToMarkers();




----------------------

the problem is that when I click on "Zoom in to show These locations", the balloon remains, as shown:


When I click "Zoom" in to show These locations" happens this:


It may depend of what?

Thanks again for your availability,
Claudio


I solved by inserting

GEvent.addListener(map, 'zoomend', function() { map.closeInfoWindow(); });

smiley
Author RE: InfoWindow Markers
martin
Super Administrator

Posts: 224
Location: Norfolk, UK.
Joined: 24.07.08
Posted on 08-05-2010 15:45
Hi.

There are two methods you can use to open the infowindow.

There is the GMap2 method and the GMarker method.

If you use the GMarker method and then that GMarker is removed from the map then that open infowindow will close automatically.

That does not happen with the GMap2 method.

You'll see in the Demo Map source code that both methods are present, the GMarker method commented out and the GMap2 method left functioning:


// here's the GMarker method
// args.clusterMarker.openInfoWindowHtml(html);

// and here the GMap2 method
map.openInfoWindowHtml(args.clusterMarker.getLatLng(), html);





If you use the GMarker method then the stray infowindow will go - disappearingfrom the map when the cluster marker is removed.

However if you open a cluster marker infowindow and drag the map a little you'll see the infowindow closes...
That's because ClusterMarker updates all cluster markers on each zoom and drag of the map.
More info on that here http://googlemapsapi.martinpearman.co.uk/forum/viewthread.php?forum_id=8&thread_id=4.

The problem doesn't exist with the new and not yet released version 2 of ClusterMarker.
In the process of re-writing much of the code i made some improvements and now a cluster marker isn't removed from the map on every zoom or drag.

Look at the new version working here http://developer.martinpearman.co.uk/phpfusion7/infusions/google_my_maps/google_my_maps.php?map_id=6.
Click a cluster marker - the blue cross icons - and drag the map, see how the infowindow (opened with the GMarker method) remains open?
Zoom in or out and the infowindow remains open until that cluster marker no longer exists and gets removed from the map.

I'd encourage you to look at version 2 if you are reasonably competent with javascript.
I've been too busy so far this year to get the new version 2 completed, debugged and documented.
But if you choose to give it atry i'm sure you'll find it far superior to version 1.3.2 and if you have questions on how to use it then post in the forum and i'll do my best to help.

Martin.

PS i just noticed that you've solved the problem with an event listener closing the infowindow - if you're happy to use that then ok otherwise you might still want to check out the version 2.
http://martinpearman.co.uk
Jump to Forum:
Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Users Online
Guests Online: 3
No Members Online

Registered Members: 237
Newest Member: Xavi
Google Maps API Projects © Martin Pearman 2010