Here is my requirement
Need to create array like this.I'm use Spring mvc + ajax + jquery + google map 3.0 I'm get these values seperately as json response.
1. city name 2. long 3. lat
var markers = [['Bondi Beach', -33.890542, 151.274856],['Coogee Beach', -33.923036, 151.259052],['Cronulla Beach', -34.028249, 151.157507],['Manly Beach', -33.80010128657071, 151.28747820854187],['Maroubra Beach', -33.950198, 151.259302]];
how to create above loop with javascript array functions.may be records more than 20,30 is it 3D array.?
please help me to sort out this issue
thanks all
below show my script code and help me to modify that to get my target result
function jsonResponse(){
var longitude=0;
var latitude=0;
var merchant='';
var total =0;
$.ajax({
url: 'merchantsList.html',
dataType: 'json',
contentType: 'application/json',
mimeType: 'application/json',
success: function(data) {
longitude=data.longitude;
latitude=data.latitude;
merchant=data.merchant;
total = data.length;
},
error:function(data,status,er) {
alert("error: "+data+" status: "+status+" er:"+er);
}
});
var markers = [['Bondi Beach', -33.890542, 151.274856],['Coogee Beach', -33.923036, 151.259052],
['Cronulla Beach', -34.028249, 151.157507],['Manly Beach', -33.80010128657071, 151.28747820854187],
['Maroubra Beach', -33.950198, 151.259302]];
var infowindow = new google.maps.InfoWindow(), marker, i;
for (i = 0; i < markers.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(latitude, longitude),
map: map
});}
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(markers[i][0]);
infowindow.open(map, marker);
};
})(marker, i));
}