在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()中,我正在Map上加载来自oData服务的多个标记。
[After clicking other tabs in master page, and later on clicking Bokk my ride tab , that time facing the issue][1]
感谢与问候, 拉欣
答案 0 :(得分:0)
初始化组件时将执行onInit函数。此方法仅调用一次,因此可以解释为什么第二次不加载地图。您可能想要尝试在onAfterRendering()函数中添加函数。