Description:
In this example we explain that how to get Current Location in Dynamic CRM using Bing Map. Or how to fetch current user Location in Bing Map in Dynamic CRM.or HTML web resource to get current Location in Dynamic CRM using Bing Map. Or how to display Bing Map in Dynamic CRM with User’s current Location using Html Web Resource.
So here we demonstrate
that how to show current location in Bing Map in Dynamic CRM.or how to display
pin point of the current location in Dynamic CRM using Bing Map. Or get current
Location from the device in Dynamic 365 and display on Bing Map using web
resource.
Below is the
html web resource code that are used to display user current location on Bing
map in Dynamic CRM.
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset = "utf-8" />
< script type='text/javascript'
src='https://www.bing.com/api/maps/mapcontrol?callback=GetMap'
async defer></script>
<script type = 'text/javascript' >
var
map, searchManager;
function
GetMap() {
map = new
Microsoft.Maps.Map('#myMap', {
credentials: 'Your Bing Map key',
center:
navigator.geolocation.getCurrentPosition(function
(position) {
var
loc = new
Microsoft.Maps.Location(position.coords.latitude, position.coords.longitude);
//Add
a pushpin at the user's location.
var
pin = new Microsoft.Maps.Pushpin(loc);
map.entities.push(pin);
})
});
reverseGeocode();
}
function
reverseGeocode() {
//If
search manager is not defined, load the search module.
if
(!searchManager) {
//Create
an instance of the search manager and call the reverseGeocode function again.
Microsoft.Maps.loadModule('Microsoft.Maps.Search', function
() {
searchManager = new Microsoft.Maps.Search.SearchManager(map);
reverseGeocode();
});
}
else
{
var
searchRequest = {
location: map.getCenter(),
callback: function (r) {
//Tell
the user the name of the result.
alert(r.address.district);
},
errorCallback: function (e) {
//If there is an error, alert the user about it.
alert("Unable to reverse geocode location.");
}
};
//Make
the reverse geocode request.
searchManager.reverseGeocode(searchRequest);
}
}
</script>
</head>
<body>
<div id = "myMap" style="position:relative;"></div>
</body>
</html>
0 comments:
Post a Comment