| 0 comments ]

Adding next link in the info box window on Google map

Hi

I have a map and it iss loading contents from an xml file. I am
displaying the markers on the map based on one particular order. I
need to to show the next infobox window from the previously opened
infobox window based on the order.

Any help appreciated !!

Thanks
jj
http://phpqa.blogspot.com

*************************************************
Larry wrote

*************************************************

Totally untested.
Put this in the code for your infoWindow (beware the quotes, match
them with the ones you are using):
html += '<a href="javascript: showNext('+i+');">Next</a>'

Put this function in the global scope:
function showNext(i) {
i++;
if (i >= gmarkers.length) { i = 0 }
GEvent.trigger(gmarkers[i], "click");

}

-- Larry

*************************************************
william wrote
*************************************************

Store references to your markers in an array, just like you would if you
were going to build a sidebar.

Build links similar to the ones that you would put in a sidebar, but for
the next marker, and put them inside your infowindow HTML.

Check if this is the last marker, and if so either don't add the link or
link back to gmarkers[0].

Something like this (not tested).

var gmarkers = [];
var maxMarkers = 28;

function createMarker(point,html) {
// create the marker
var marker = new GMarker(point);

// store a reference in the gmarkers array
gmarkers.push(marker);

// build the link
var n = gmarkers.length;
var link = '<br><a href="javascript:GEvent.trigger(gmarkers[' + n +
'], \'click\')"> Next </a>';

// is this the last marker?
if (n < maxMarkers) {
html += link;
}

// handle the click
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;

}

Wasn't it jey jey who wrote:

*************************************************
jj wrote

*************************************************

Thanks Larry and Mike for the answers.
It worked out for me on my map.

Thanks again for your time you have spend for.

on function createMarker, I have added " gmarkers.push(marker); "

then I wrote function ;

function myclick(i)
{
i++;
GEvent.trigger(gmarkers[i], "click");

}

then called the function like

" html += separator + '<span style="text-align:right;"><a
href="javascript:myclick(\''+ i +'\');">Next Location</a></span>'; "

Hope this helpful to somebody


thanks
jj
http://phpqa.blogspot.com

0 comments

Post a Comment

Please put your comments here. your questions, your suggestions, also what went wrong with me.