我添加了简单(来自示例)代码,以显示带有各种控件的地图。 地图显示正常但不显示控件,并且控制台中显示错误“TypeError:null has no properties”错误。
我尝试过一次添加一个控件,但添加任何控件都会产生错误。
我搜索了这个但没找到任何东西。它必须非常简单。
下面是代码的摘录。 任何帮助将不胜感激
{
nokia.Settings.set("app_id", "myid");
nokia.Settings.set("app_code", "mycode");
// Use staging environment (remove the line for production environment)
nokia.Settings.set("serviceMode", "cit");
(document.location.protocol == "https:") &&
nokia.Settings.set("secureConnection", "force");
var mapContainer = document.getElementById(mySelf.options["id"]);
// Create a map inside the map container DOM node
if(mySelf.options["controls"] == true){
controls = [
new nokia.maps.map.component.ZoomBar(),
new nokia.maps.map.component.Behavior(),
new nokia.maps.map.component.TypeSelector(),
new nokia.maps.map.component.Traffic(),
new nokia.maps.map.component.PublicTransport(),
new nokia.maps.map.component.DistanceMeasurement(),
new nokia.maps.map.component.Overview(),
new nokia.maps.map.component.ScaleBar(),
new nokia.maps.positioning.component.Positioning(),
new nokia.maps.map.component.ContextMenu(),
new nokia.maps.map.component.ZoomRectangle(),
new nokia.maps.map.component.TrafficIncidents()
];
} else {
controls = [
];
}
this.map = new nokia.maps.map.Display(mapContainer, {
center: [52.51, 13.4],
zoomLevel: 10,
components: controls
});
}
答案 0 :(得分:1)
解决。地图api查看名为self的全局变量。我在我的一个函数中设置了一个self = this with out var。地图api真的得到了它的短裤。花了我几个小时才找到这个。希望它可以帮助别人。