Hi,
I have a KML with a route which I display on Google Maps via the GGeoXml
. Because I want to have Placemarks from the KML in a sidebar (next to the map) I have created a KMl parser which displays them (I don't want to use the geoxml).
I've successfully created the sidebar which interacts with the map. The only problem is that i don't want to recreated the Infowindow on the map (from the sidebar) I want to use the existing one, which is generated from GGeoXml
. How can i open it from the sidebar??? If not possible can I disable the GGeoXml
infowindow and use the one from the sidebar??
Here's the code (this is just a concept code, not a final version):
$(document).ready(function() {
map = new GMap2(document.getElementById("map_canvas"));
map.addControl(new GLargeMapControl());
map.setCenter(new GLatLng(***,***), 11);
map.addControl(new GLargeMapControl());
function displayPoint(marker, index){
map.setCenter( new GLatLng(marker.lng, marker.lat) );
map.panTo( map.getCenter() );
map.openInfoWindow( map.getCenter() );
}
var MapIt = function( file ){
map.clearOverlays();
geoXml = new GGeoXml("http://***/kml/" + file + ".kml");
geoXml.gotoDefaultViewport(map);
var listener = GEvent.addListener(geoXml, "load", function() {
map.setCenter(geoXml.getDefaultCenter(), 11);
map.addOverlay(geoXml);
GEvent.removeListener(listener);
});
var markers = [];
$.ajax({
type: "GET",
url: 'parse.php?route=' + file,
dataType: "json",
success: function(data){
$.each(data, function(j, point){
markers[j] = point;
});
$(markers).each(function(i,marker){
$("<li />")
.html(marker.name +" "+ i)
.click(function(){
displayPoint(marker, i);
})
.appendTo("#list");
GEvent.addListener(marker, "click", function(){
displayPoint(marker, i);
});
});
}
});
}
var ShowTrail = function( file ){
MapIt(file);
$("#histogram").empty();
$('<img />').attr('src','http://***/kml/' + file + '.png').appendTo("#histogram");
}
$("a.route").click(function(e){
e.preventDefault();
ShowTrail( $(this).attr("rel") );
});
});
Thanks in advance!