Click here to Skip to main content
14,334,974 members

SharePoint

 
Questionget client id by id of server element Pin
xpwolf11-Apr-13 9:03
memberxpwolf11-Apr-13 9:03 
QuestionHow to calculate score in sharepoint designer 2010 Pin
angga risky margiyanti9-Apr-13 17:38
memberangga risky margiyanti9-Apr-13 17:38 
QuestionSharePoint Designer 2010 - Disable Textbox when Checkbox = True on EditForm.aspx Pin
LeslieC4-Apr-13 10:32
memberLeslieC4-Apr-13 10:32 
AnswerRe: SharePoint Designer 2010 - Disable Textbox when Checkbox = True on EditForm.aspx Pin
Lin ann22-Dec-13 21:54
memberLin ann22-Dec-13 21:54 
Questionpopulate sharepoint list from user profile service sync Pin
vanita khatnani1-Apr-13 18:52
professionalvanita khatnani1-Apr-13 18:52 
QuestionPPS analysis service connection issues Pin
Abhilashpanda1128-Mar-13 21:45
memberAbhilashpanda1128-Mar-13 21:45 
QuestionUpdatePanel inside Dropdownlist not Working on Selected Index changed Event Pin
balaji101021-Mar-13 2:13
memberbalaji101021-Mar-13 2:13 
QuestionHow to show multiples pushpins in one map using REST services from Maps Ajax Control 7.0 and SharePoint 2010 list? Pin
Member 990179120-Mar-13 8:32
memberMember 990179120-Mar-13 8:32 
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].name);

if (result &&
result.resourceSets &&
result.resourceSets.length > 0 &&
result.resourceSets[0].resources &&
result.resourceSets[0].resources.length > 0) {


// The loop
for (var i = 0; i < 1; i++) {

// Add a pushpin at the found location
var location = new Microsoft.Maps.Location(result.resourceSets[0].resources[0].point.coordinates[0], result.resourceSets[0].resources[0].point.coordinates[1]);
var pin = new Microsoft.Maps.Pushpin(location);

// Create the infobox for the pushpin
pinInfobox = new Microsoft.Maps.Infobox(pin.getLocation(), infoboxOptions);
pin.Title = "teste " + i; //usually title of the infobox
pin.Description = result.resourceSets[0].resources[0].name; //information you want to display in the infobox

// Add handler for the pushpin click event.
Microsoft.Maps.Events.addHandler(pin, 'click', displayInfobox);

// Hide the infobox when the map is moved.
Microsoft.Maps.Events.addHandler(map, 'viewchange', hideInfobox);

alert(i);

map.entities.push(pin);
map.entities.push(pinInfobox);
}
}
}

function displayInfobox(e) {
if (e.targetType == 'pushpin') {
pinInfobox.setLocation(e.target.getLocation());
pinInfobox.setOptions({ title: e.target.Title, description: e.target.Description, visible: true });
}
}

function hideInfobox(e) {
if (e.targetType == 'pushpin') {
pinInfobox.setOptions({ visible: false });
}
}


QuestionInfoPath form not loaded when i start workflow Pin
Honeyboy_2011-Mar-13 3:24
memberHoneyboy_2011-Mar-13 3:24 
QuestionPackage not deploying new list Pin
Aptiva Dave7-Mar-13 12:12
memberAptiva Dave7-Mar-13 12:12 
AnswerRe: Package not deploying new list Pin
Aptiva Dave7-Mar-13 12:38
memberAptiva Dave7-Mar-13 12:38 
QuestionProblwm when i add web part into site definition ? Pin
Honeyboy_205-Mar-13 0:52
memberHoneyboy_205-Mar-13 0:52 
AnswerRe: Problwm when i add web part into site definition ? Pin
Ingo5-Mar-13 1:06
memberIngo5-Mar-13 1:06 
GeneralRe: Problwm when i add web part into site definition ? Pin
Honeyboy_205-Mar-13 1:09
memberHoneyboy_205-Mar-13 1:09 
QuestionInfoPath form on Submit! Open as an Outlook email Message using C# Pin
lasertracs26-Feb-13 8:28
memberlasertracs26-Feb-13 8:28 
AnswerRe: InfoPath form on Submit! Open as an Outlook email Message using C# Pin
Ingo26-Feb-13 20:58
memberIngo26-Feb-13 20:58 
QuestionUpdating a content type with new column, but need to add the default value to existing items Pin
Aptiva Dave14-Feb-13 4:55
memberAptiva Dave14-Feb-13 4:55 
GeneralRe: Updating a content type with new column, but need to add the default value to existing items Pin
Ingo14-Feb-13 6:02
memberIngo14-Feb-13 6:02 
GeneralRe: Updating a content type with new column, but need to add the default value to existing items Pin
Aptiva Dave14-Feb-13 8:17
memberAptiva Dave14-Feb-13 8:17 
AnswerRe: Updating a content type with new column, but need to add the default value to existing items Pin
Ingo14-Feb-13 21:31
memberIngo14-Feb-13 21:31 
QuestionAccessing SharePoint information regarding specific documents Pin
muneebalikiyani13-Feb-13 18:04
membermuneebalikiyani13-Feb-13 18:04 
AnswerRe: Accessing SharePoint information regarding specific documents Pin
Ingo13-Feb-13 21:57
memberIngo13-Feb-13 21:57 
QuestionPopulating list columns in Sharepoint 2010 custom doc library Pin
Aptiva Dave10-Feb-13 7:15
memberAptiva Dave10-Feb-13 7:15 
AnswerRe: Populating list columns in Sharepoint 2010 custom doc library Pin
AnandSharmaUK20-Feb-13 0:27
memberAnandSharmaUK20-Feb-13 0:27 
QuestionSoftware and Hardware requirements for document shareing Pin
HemadriT7-Feb-13 7:24
memberHemadriT7-Feb-13 7:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.