How to show multiples pushpins in one map using REST services from Maps Ajax Control 7.0 and SharePoint 2010 list?
-
Hi All, I’m trying to make a map that get address data from a SharePoint 2010 list and add pushpins according to each address. I’m using REST services from Maps Ajax Control 7.0 to transform locations into coordinates. The map is working, but I think the code is not correct. There is a loop placed on “function GeocodeCallback(result)”, but I can’t understand why it is there. If I delete the loop code line, the map doesn’t show pushpins. Please, someone could explain why I need the loop. If the loop is incorrect, please, show me how to fix it. I am not a programmer but I am learning to be one. My code is posted below: Thank you all for helping me. var map = null; var pinInfobox = null; var query; // InfoBox var infoboxOptions = { offset: new Microsoft.Maps.Point(0, 15), visible: false }; var mapOptions = { credentials: "XXXXXXXXX", center: new Microsoft.Maps.Location(47.609771, -122.2321543125), zoom: 12, mapTypeId: Microsoft.Maps.MapTypeId.road } jQuery(document).ready(function ($) { GetMap(); }); function GetMap() { // Initialize the map map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), mapOptions); map.getCredentials(MakeGeocodeRequest); } function MakeGeocodeRequest(credentials) { var listUrl = "http://intranet/Teste/\_vti\_bin/listdata.svc/Carona"; $.getJSON(listUrl, function (data) { var count = 0; $.each(data.d.results, function (i, item) { alert(item.Address); query = item.Address + " " + item.City + " " + item.State; var geocodeRequest = "http://dev.virtualearth.net/REST/v1/Locations/" + query + "?output=json&jsonp=GeocodeCallback&key=" + credentials; CallRestService(geocodeRequest); }); }); } function CallRestService(request) { var script = document.createElement("script"); script.setAttribute("type", "text/javascript"); script.setAttribute("src", request); document.body.appendChild(script); } function GeocodeCallback(result) { alert("Found location: " + result.resourceSets[0].resources[0].na</x-turndown>