Markers are showing correctly in Firefox, not in Chrome or Opera. I think i have some scope problem, as the db_locations array is ‘sometimes’ losing it’s value and is arriving empty to buildMap(). I said ‘sometimes’ because when i add alert(db_locations) in BuildMap() in the first page refresh ‘tends’ to show the actual values.
Appreciate any help.
var db_locations = new Array();
$.ajax({
type: "GET",
url: "markers_xml.php",
dataType: "xml",
success: function(xml) {
...
var inside = new Array(val1,val2,val3 etc);
db_locations[i]=inside;
...
});
function buildMap() { /* this is the init function */
...
setMarkers(map, db_locations);
...
}
function setMarkers(map, locations) {
// markers loop
}
window.onload = buildMap;
Most likely the AJAX request is not returning on time. Wrap the AJAX call in a function, call buildMap within the Ajax success function, and call the AJAX request wrapping function when the window loads.