我想在Google地图上添加标记。问题是我的网站是'Ext.Container'而不是'Ext.map',因为我需要一个标题栏。这就是getMap()不适合我的原因。有机会运行吗?
这是绘制地图的功能:
showMapCommand: function() {
var record = this.getRecord();
var map = new Ext.Map({
title: 'Map',
useCurrentLocation: false,
mapOptions: {
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: new google.maps.LatLng(record.data.latitude, record.data.longitude),
mapTypeControl: false,
zoomControl: true,
overviewMapControl: false,
panControl: false,
rotateControl: false,
scaleControl: false,
controlPosition: false,
navigationControl: false,
streetViewControl: false,
backgroundColor: 'transparent',
disableDoubleClickZoom: true,
zoom: 15,
keyboardShortcuts: false,
scrollwheel: false
}
});
var marker = new google.maps.Marker ({
map: map,
animation: google.maps.Animation.DROP,
position: new google.maps.LatLng(record.data.latitude, record.data.longitude),
icon: 'resources/images/marker.png'
});
this.add([
map
]);
},
控制台的错误消息:
Uncaught Error: Invalid value for property <map>: [object Object]
答案 0 :(得分:0)
试试这个:
var marker = new google.maps.Marker ({
map: map.map,
animation: google.maps.Animation.DROP,
position: new google.maps.LatLng(record.data.latitude, record.data.longitude),
icon: 'resources/images/marker.png'
});
希望它有所帮助 -
修改:
为什么不使用Ext.defining地图创建单独的文件,只需将其添加为容器的项目即可。那样你可以this.getMap()