установите маркер google в sencha touch
У меня есть некоторые проблемы, когда я устанавливаю маркер, я нашел этот код для создания карты google, и он работает. Но теперь я хочу установить маркер с моей текущей позицией, и проблема в том, что я не знаю, где находится объект google map, Без этого маркер не отображается.
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');          
                }
              }
           })
    });
2 ответа:
Проведя день в поиске через google, я основал это решение:
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); } });