I have a map, I am trying to pull in marker points from my data base, and create an array and then use that array to plot each latitude and longitude point on the map. Now I have tried a few things here but, but whenever I test it, I just get one point on the map and its like in asia, when in reality the longitude and latitude points to pennsylvania. I think it just packing all of the information into the array and trying to plot, but I am not sure. Really stuck here any help would be appreciated.
<script type="text/javascript">
$(function () {
var arraddress = new Array();
$.ajax({
url: 'http://example.com/22/www/ba.php',
data: '',
dataType: 'json',
success: function (data) {
$.each(data, function (key, val) {
var lng = val['lng'];
var lat = val['lat'];
var id = val['id'];
var state = val['state'];
arraddress[key] = lat + ":" + lng + ":" + state + ":" + id;
//Set up the map
var APIKEY = "ed24c9065bb55c1090d3d76e7ab8577e";
var cloudmade = new CM.Tiles.CloudMade.Web({
key: APIKEY
});
var map = new CM.Map('mapdiv', cloudmade);
map.setCenter(new CM.LatLng(39.9, -98.5), 4);
//Add the markers from the array
var arLen = arraddress.length;
for (var i = 0, len = arLen; i < len; ++i) {
var onMarker = arraddress[i];
var dat = arraddress[i].split(":");
var mlat = dat[0];
var mlon = dat[1];
var mName = dat[2];
var thisMarker = new CM.Marker(new CM.LatLng(mlon, mlat), {
title: state
})
map.addOverlay(thisMarker);
}
})
}
});
});
}
</script>