Hi Everybody,
My very first question in here. I am building a google maps by getting the data from json object given from external php file, in there It gets me the list of restaurants (in this case 4 restaurants) and their info, and with this info I build the markers on the map and then show the list of restaurants, and when I click the name of restaurant it should show it in the map, from the marker, and this function is not working, here is the code:
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
type:"GET",
url:"proxy.php",
dataType:"json",
contentType:"text/json",
success:function(res){
$.post('getinfo.php', {data: res}, function(data){
response = jQuery.parseJSON(data);
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("google_map_div"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(0,0),0);
var side_bar_html = "";
var gmarkers = [];
var htmls = [];
var i = 0;
function createMarker(point,name,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
gmarkers[i] = marker;
htmls[i] = html;
side_bar_html += '<a href="javascript:openInsideMap(' + i + ')">' + name + '</a><br>';
return marker;
//
}
function openInsideMap(i){
alert("WORKING" + i);
gmarkers[i].openInfoWindowHtml(htmls[i]);
}
var bounds = new GLatLngBounds();
for(i=0; i<response.length;i++){
var j = i + 1;
// obtain the attribues of each marker
var lat = parseFloat(response[i].langt);
var lng = parseFloat(response[i].longt);
var point = new GLatLng(lat,lng);
var html = response[i].localName + ": " + response[i].localAddress;
if(response[i].tapaName == ''){
var label = j + ". " + response[i].localName + " - " + response[i].localAddress;
}else{
var label = j + ". " + response[i].localName + " - " + response[i].localAddress + "<br /> " + response[i].tapaName;
}
// create the marker
var marker = createMarker(point,label,html);
map.addOverlay(marker);
// ==== Each time a point is found, extent the bounds ato include it =====
bounds.extend(point);
}
document.getElementById("side_bar").innerHTML = side_bar_html;
map.setZoom(map.getBoundsZoomLevel(bounds));
map.setCenter(bounds.getCenter());
}
});
}
});
WHEN I BROWSE IT IN MOZILLA OR GCHROME, IT SAYS THAT function openInsideMap(i){ IS NOT DEFINED openInsideMap is not defined
THANK YOU VERY MUCH FOR YOUR HELP, AND THE LINK TO CHECK IT IS: http://www.gsi.dec.usc.es/santiagoetapas/testStage.php