Google maps Sencha touch-无法谷歌地图标记
我正在学习SenchaTouch,并尝试在谷歌地图上放置标记。我已经在网上查看了大多数示例,但是我无法让marker和infoWindow正常工作。下面是我的代码:Google maps Sencha touch-无法谷歌地图标记,google-maps,extjs,sencha-touch,Google Maps,Extjs,Sencha Touch,我正在学习SenchaTouch,并尝试在谷歌地图上放置标记。我已经在网上查看了大多数示例,但是我无法让marker和infoWindow正常工作。下面是我的代码: myApp.views.MapCard = Ext.extend(Ext.Panel, { id: "mapcard", layout: 'card', initComponent: function() { this.map = new Ext.Map({ useCu
myApp.views.MapCard = Ext.extend(Ext.Panel, {
id: "mapcard",
layout: 'card',
initComponent: function() {
this.map = new Ext.Map({
useCurrentLocation: true,
mapOptions: {
zoom: 12,
},
});
this.panel = new Ext.Panel({
layout: 'fit',
items: this.map,
});
this.items = this.panel;
myApp.views.MapCard.superclass.initComponent.call(this);
refresh = function(theMap) {
var geoTag = {
lat: '47.584863',
longi: '-122.147026',
text: 'Hello World',
}
addMarker(geoTag, theMap);
}
addMarker = function(geoTag, theMap) {
var latLng = new google.maps.LatLng(geoTag.lat, geoTag.longi);
var marker = new google.maps.Marker({
map: theMap.map,
position: latLng
});
google.maps.event.addListener(marker, "click", function() {
geoTagBubble.setContent(tweet.text);
geoTagBubble.open(theMap.map, marker);
});
};
geoTagBubble = new google.maps.InfoWindow();
refresh(this.map);
},
});
Ext.reg('mapcard', myApp.views.MapCard);
我也无法获取用户的当前位置,我非常确定在初始化组件期间没有加载映射。我将调用一个json服务来拉取lat/lon并稍后循环。如果有更好的实现,请让我知道
非常感谢 下面是一个非常简单的示例应用程序,演示了这一点: 您可以在view source下或GitHub上找到源代码: 以下是将标记添加到地图的面板: 警告:Sencha Touch 1.x中存在一个阻止嵌入式谷歌地图接收任何点击事件的漏洞 在包含sencha-touch.js之后,您需要包含此修补程序,以便地图上的任何单击侦听器都可以工作: