2012-01-05 35 views
1

我学习sencha触摸并尝试在谷歌地图上放置标记。我在网上查看了大部分示例,但我无法获得标记和infoWindow的工作。下面是我的代码:Sencha触摸 - 无法谷歌地图标记

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); 

我也无法获得用户的当前位置,我敢肯定的是,地图是不是initComponent过程中加载。我会调用一个json服务来拉动纬度/经度,然后循环播放。如果有更好的实施,请让我知道!

谢谢!

回答

3

这里有一个相当小的示例应用程序演示了此: http://septa.mobi

下可以找到查看源代码或在GitHub上的源代码:其中标志物被添加到地图 https://github.com/mjumbewu/Septnuts/

这里的面板: https://github.com/mjumbewu/Septnuts/blob/master/src/Septnuts/MapPanel.js

警告:存在这样可防止接受任何点击,甚至嵌入谷歌地图煎茶触摸1.x的一个bug TS

您需要包括包括煎茶,touch.js为了任何点击听者在地图上的工作后,该修补程序: https://github.com/mjumbewu/Septnuts/blob/master/src/sencha-maptouch-patch.js