在SAP UI5中,谷歌地图不是第二次加载。我正在 attachPatternMatched(( 函数上加载地图。那么,我该如何解决此问题呢?
onInit: function() {
var that = this;
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
oRouter.getRoute("master").attachPatternMatched(this.setMapData, this);
},
setMapData: function() {
var that = this;
this.getView().getModel("BookMyRideModel").read("/Stops", {
success: function(response) {
var arry = [];
for (var k = 0; k < response.results.length; k++) {
var lat = response.results[k].Latitude;
var long = response.results[k].Longitude;
var address = response.results[k].Stop_Name;
var pincode = response.results[k].Pincode;
var id = response.results[k].Stop_Id;
arry.push({
"lat": lat,
"long": long,
"addr": address,
"pin": pincode,
"key": id
});
}
that.setMarkerForMap(arry);
},
error: function(response) {
}
});
},
setMarkerForMap: function(array) {
var that = this;
var markersarry = [];
var map = new google.maps.Map(document.getElementById('googleMap'), {
center: new google.maps.LatLng(parseFloat(12.9715),
parseFloat(77.5945626)),
zoom: 2,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
}
在setMapForMarkers((中,我正在地图上加载来自oData服务的多个标记。
[After clicking other tabs in master page, and later on clicking Bokk my ride tab , that time facing the issue][1]
谢谢和问候, 拉欣
应用程序快照
onInit 函数在组件初始化时执行。此方法仅调用一次,以便解释为什么第二次未加载地图。您可能想尝试在 onAfterRendering(( 函数中添加您的函数。