Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating Javascript array from ajax results from database
    primarykey
    data
    text
    <p>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. </p> <pre><code> &lt;script type="text/javascript"&gt; $(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 &lt; 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); } }) } }); }); } &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload