Get Address and Information from Map
Javascript Source
//--- Load SP Maps
function
initMapApi() {
var
mapDiv = 'map'; //id of the div where the map should appear
var
mapType = 'default';
var
mapLanguage = 'A';
var
proxyUrl = '';
var
apiClientKey = 'your-api-key';
SANGC_LoadMapViewer(mapDiv, mapType, mapLanguage, proxyUrl, apiClientKey);
AssignUserEvents();
};
//======= Assign User Events so that to be trigered
function
AssignUserEvents() {
//------- Map Events.
SANGC_OnMapLoaded = ClientOnMapLoaded;
SANGC_OnMouseClick = ClientOnMouseClick;
SANGC_OnIdentify = ClientOnIdentify;
};
//--- Callback function for Map Loaded Event
function
ClientOnMapLoaded() {
return;
};
//--- Callback function for Identify Click event
function
ClientOnIdentify(aResult) {
document.getElementById("locationInformationTable").innerHTML = '';
document.getElementById("noresultsdiv").innerHTML = '';
if
((aResult == null) || (aResult.length == 0)) {
document.getElementById("noresultsdiv").innerHTML = "No Result";
} else
{
for
(var
i = 0; i <= aResult.length - 1; i++) {
alert(aResult[i].BuildingNumber +
aResult[i].ZipCode +
aResult[i].AdditionalNumber +
aResult[i].StreetAr +
aResult[i].StreetEn +
aResult[i].DistrictAr +
aResult[i].DistrictEn +
aResult[i].CityAr +
aResult[i].CityEn +
aResult[i].ServiceNameAr +
aResult[i].ServiceNameEn +
aResult[i].HasParcel +
aResult[i].RegionAr +
aResult[i].RegionEn +
aResult[i].Latitude +
aResult[i].Longitude);
}
}
};
function
ClientOnMouseClick(px, py, sx, sy) {
var
locationObj = document.getElementById('locationStatus');
locationObj.innerHTML = '
Longitude: '
+ px.toString() + ", Latitude: "
+ py.toString();
};
HTML Source
<div class="container"
style="background-color:#DCE8E0;">
<div class="row">
<div class="col-md-12">
<div style="margin-bottom:20px;">
<h1>National Address Maps Api Portal - Sample - Get Location Info.</h1>
</div>
<div style="position:relative;height:500px;width:100%;">
<div id="map"
style="width:100%;height:100%; margin:0px; padding:0px; background-color:white;"></div>
</div>
<div id="Div4"
style="background-color:Highlight; height:10px; width:100%; padding-bottom:18px; font-weight:bold;">Location Information</div>
<div id="locationStatus"
style="background-color:Highlight; height:100%; width:100%; font-family:Calibri;"></div>
<div id="resultsDiv"
style="background-color:Highlight; height:100%; width:100%; font-family:Calibri;">
<table id="locationInformationTable"
border="1"></table>
<div id="noresultsdiv"></div>
</div>
</div>
</div>
</div>