Archive
Posts Tagged ‘Maps’
Dynamics 365 Mobile Client – Script to get Longitude and Latitude and pin to Maps
January 14, 2017
2 comments
With the new Dynamics 365 Mobile client, we got a new API Xrm.Utility.getCurrentPosition which returns the current location coordinates.
This API only works with Mobile Client and referring this in Web Application would cause script error.
Pre-requisite:
We need to Enable User Location setting on the device
- Go to Settings -> Device Integration Settings
- Enable “User Content and Location”
Script to get coordinates:
function onload() {
var isCrmForMobile = (Xrm.Page.context.client.getClient() == “Mobile”);if (isCrmForMobile) {
Xrm.Utility.getCurrentPosition().then
(function (location) {
Xrm.Utility.alertDialog(“Latitude: ” + location.coords.latitude +
“, Longitude: ” + location.coords.longitude);
},
function (error) {
Xrm.Utility.alertDialog(error.message);
})
}
}
HTML File to Read Coordinates and Show in Map
🙂
Categories: Dynamics 365
Dynamics 365, Maps, Mobile Client Coordinates