Google maps api 3 在sencha touch中设置谷歌标记
我有一些问题,当我设置了一个标记,我发现这个代码生成谷歌地图,它的工作。但是现在我想用我的当前位置设置一个标记,问题是我不知道谷歌地图对象在哪里,没有这个标记就不会显示Google maps api 3 在sencha touch中设置谷歌标记,google-maps-api-3,sencha-touch,google-maps-markers,Google Maps Api 3,Sencha Touch,Google Maps Markers,我有一些问题,当我设置了一个标记,我发现这个代码生成谷歌地图,它的工作。但是现在我想用我的当前位置设置一个标记,问题是我不知道谷歌地图对象在哪里,没有这个标记就不会显示 this.mapg = new Ext.Map({ useCurrentLocation:true, geo:new Ext.util.GeoLocation({ autoUpdate:true, timeout:2000,
this.mapg = new Ext.Map({
useCurrentLocation:true,
geo:new Ext.util.GeoLocation({
autoUpdate:true,
timeout:2000,
listeners:{
locationupdate: function(geo) {
center = new google.maps.LatLng(geo.latitude, geo.longitude);
// Set the marker
marker = new google.maps.Marker({
map:geo.map,//??? No idea where is the google map object
position: center
});
if (this.rendered)
this.update(center);
else
this.on('activate', this.onUpdate, this, {single: true, data: center});
},
locationerror: function(geo){
alert('got geo error');
}
}
})
});
它在:
mapg.map
您不显示mapg是什么成员,但您可以显式访问它。在花了一天时间通过谷歌搜索后,我发现了这个解决方案:
ascom.views.MapG = Ext.extend(Ext.Panel, {
layout:'card',
initComponent: function(){
var infowindow = new google.maps.InfoWindow({
content: 'prova'
});
this.map = new Ext.Map({
mapOptions : {
zoom: 12,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.DEFAULT
}
},
useCurrentLocation: true,
listeners: {
maprender : function(comp, map){
var marker = new google.maps.Marker({
position: map.center,
title : 'Infofactory HQ',
map: map
});
infowindow.open(map, marker);
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
}
}
});
this.panel = new Ext.Panel({
layout:'fit',
items:this.map,
dockedItems:[
{
xtype:'toolbar',
title:'Map GO'
}
]
});
this.items = this.panel;
ascom.views.MapG.superclass.initComponent.call(this);
}
});
很好的例子,但是infoWindow只会打开,因为它是显式启动的-infoWindow.open。单击事件侦听器似乎不适用于我。我还尝试了“点击”——没有运气让它响应用户交互——在iOS6和iOS7上进行了测试。还有人知道这个问题吗?