Hi all, I have a default map that loads with the users current location on it.
function GetMap() {
// Set the default page map and view settings
mapOtions = {
credentials: credentials,
mapTypeId: Microsoft.Maps.MapTypeId.road,
animate: false,
zoom: startingZoom,
center: new Microsoft.Maps.Location(geoLocationProvider)
};
// Initialize the map
map = new Microsoft.Maps.Map(document.getElementById("myMap"), mapOtions);
geoLocationProvider = new Microsoft.Maps.GeoLocationProvider(map); // Initialize the location provider
geoLocationProvider.getCurrentPosition({ successCallback: displayCenter })// Get the user's current location, set as default
}
function displayCenter(args) {
//Display the users location when the goe location request returns
alert("May we use your Location?")
var locationPoint1 = args.center.latitude;
var locationPoint2 = args.center.longitude;
var lat = document.getElementById("hdnLatitude").value = locationPoint1;
var lng = document.getElementById("hdnLongitude").value = locationPoint2;
map.entities.clear();
var pushpin = new Microsoft.Maps.Pushpin(map.getCenter(), null);
map.entities.push(pushpin);
pushpin.setLocation(new Microsoft.Maps.Location(locationPoint1, locationPoint2));
}
The user will search for a location that is within a selected distance from them, and I want to return a map of all of the locations that are in my database, and that are within the selected range that the user selected. I cannot get the map to load. here is my Javascript;
function GetResultsMap() {// Set the results map and view settings
var view;
if (document.getElementById("hdnLatitude").value == '' || document.getElementById("hdnLatitude").value == null ||
document.getElementById("hdnLongitude").value == '' || document.getElementById("hdnLongitude").value == null) {
view = document.getElementById('<%= lblLatLong.ClientID %>').innerHTML;
}
else {
view = document.getElementById("hdnLatitude").value + "," + document.getElementById("hdnLongitude").value;
}
mapOtions = {
credentials: credentials,
mapTypeId: Microsoft.Maps.MapTypeId.road,
animate: false,
zoom: resultsZoom,
center: new Microsoft.Maps.Location(view)
};
// Initialize the map
map = new Microsoft.Maps.Map(document.getElementById("myMap"), mapOtions);
}
I am new to javascript, but I understand it somewhat. I would like to loop through the results retreived from my database, and set a push pin on my map showing each location. Can anyone direct me to a good tutorial to learn how to do this? Any direction would be helpful. Thank you.
mark a fisher