Я интегрировал карту Bing для отображения маркера карты из почтового индекса. Пост пройдет как вход для карты. Если я пойду на карту в первый раз с почтовым индексом, он будет работать нормально. После возвращения со страницы карты, если я сохраню приложение идеальным в течение 30 минут, тогда, если я перенаправлю на страницу карты Bing с почтовым индексом, оно не будет отображать маркер на карте.
bingmap.ts
getMarker() {
Microsoft.Maps.loadModule(['Microsoft.Maps.SpatialDataService',
'Microsoft.Maps.Search'], () => {
this.searchManager = new Microsoft.Maps.Search.SearchManager(this.map);
});
var url = environment.baseurl + '/tables/Property?$filter=IncidentId eq ';
const data = this.passdataservice.bingMapdata.mapparam;
const searchrequest = data.postcode;
let geocodeRequest = {
where: searchrequest,
callback: this.generateMarker,
errorCallback: (e) => {
},
userData: { that: this }
};
this.searchManager.geocode(geocodeRequest);
}
// end of fucntion
// frucntion for generating marker
generateMarker(geocodeResult, userData) {
userData.that.clearOldMapsData();
let that = userData.that;
console.log('result data fucntion');
console.log(geocodeResult);
console.log('userData');
console.log(userData.that);
if (geocodeResult && geocodeResult.results && geocodeResult.results.length > 0) {
let latLongDetails: LatLongDetail[] = [];
for (const result of geocodeResult.results) {
let latLongRecord = new LatLongDetail();
latLongRecord.lat = result.locations[0].latitude;
latLongRecord.long = result.locations[0].longitude;
latLongDetails.push(latLongRecord);
}
for (var i = 0; i < 1; i++) {
let loc = new Microsoft.Maps.Location(latLongDetails[i].lat, latLongDetails[i].long);
let title = {
title: latLongDetails[i].buildingName,
icon: '../../assets/images/map_marker.png'
}
// custom map setview
that.map.setView({
mapTypeId: Microsoft.Maps.MapTypeId.road,
center: new Microsoft.Maps.Location(latLongDetails[i].lat, latLongDetails[i].long),
zoom: 7
});
const data = that.passdataservice.bingMapdata.mapparam;
// const searchrequest = data.buildingName + ", " + data.dependentLocality + "," + data.postcode;
const searchrequest = data.postcode;
let pin = new Microsoft.Maps.Pushpin(loc, title);
var infobox = new Microsoft.Maps.Infobox(loc, {
title: data.postcode,
description: searchrequest,
visible: false
});
infobox.setMap(that.map);
Microsoft.Maps.Events.addHandler(pin, 'click', () => {
infobox.setOptions({ visible: true });
});
that.map.entities.push(pin);
that.mapvisible = true;
}
}
} // end of fucntion