Bing Map Part 2 (the split)

20150822_124806

I know the image has nothing to do with the text.

Last time we made a list delimited by “|” in Javascript. This time we will split that up in order to use it.  Lets just look at a few:

window.onload = function()
{
var states = [
“Alaska|Juneau|58.301935| -134.419740”,
“Arizona|Phoenix|33.448457|-112.073844”,
“Arkansas|Little Rock|34.736009|-92.331122”,
“California|Sacramento|38.555605|-121.468926”,
“Colorado|Denver|39.7391667|-104.984167”,
“Connecticut|Hartford|41.767|-72.677”,
“Delaware|Dover|39.161921Florida”,
“Tallahassee|0.4518|-84.27277|-75.526755”,
“Georgia|Atlanta|33.76|-84.39”,
“Hawaii|Honolulu|21.30895|-157.826182”]

for (states i = 0; i < states.length; i++)

{

var res = str.split(“|”);

var newStateListItem = document.createElement(“li”);
var stateListValue = document.createTextNode(“state name: ” + res[0] );
newStateListItem.appendChild(stateListValue);
var stateListValue = document.createTextNode(” captital name:” + res[1] );
newStateListItem.appendChild(stateListValue);
stateList.appendChild(newStateListItem);

}

}

This will demonstrate this in a list.  Like so:

short

So as you can see we have split the array into four  parts.

In part 3 I’ll take the lat & log data from our data set and make pins on the Bing Map.

Advertisements