I have used VB to create a JSON object of markers.
Dim nearbyLocations = CType(sqldata.Select(DataSourceSelectArguments.Empty),
DataView)
For Each location As DataRowView In nearbyLocations
markers.Add(
String.Format(
"{{ title: ""AccName:{0}"", position: new google.maps.LatLng({1}, {2})}}",
location("accgrpname"),
location("Lat"),
location("Long")))
Next
Dim locationsJson = "[" & String.Join(",", markers.ToArray()) & "]"
How would i reference this object in javascript to plot on a map?
Final JSON is the following:
[{ title: "AccName: Name", position: new google.maps.LatLng(51.0000, -0.1000)}]
Thanks
I assume you use AJAX call to load the JSON object created using VB code. You may use JQuery to make ease of your ajax call and the data you received will be converted to JavaScript object for you.
a quick sample looks like (un-tested code):
$.ajax({
url: service, //your VB service
dataType: 'json', //could be JSONP
success: function(data){ var mk = new google.maps.Marker(data); }
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.