2012-05-08 15 views
0

我有一個帶有標記的地圖,我想讓標記點擊表示一些基本信息。如何鏈接地圖標記到Sencha Touch上的詳細視圖(建築師2)

我是新來煎茶,我需要諮詢什麼,我應該監聽功能implemante來獲得同樣的效果,我在列表項點擊:

例如,這是我的maprender功能的代碼

var lat = 37.428607; 
var lng = -122.169344; 


var latLng = new google.maps.LatLng(lat, lng); 


var marker = new google.maps.Marker({ 
    position: latLng, 
    map: gmap, 
    draggable: false, 
    animation: google.maps.Animation.DROP, 
    title: 'cool' 
}); 


var contentString = 'bla bla bla'; 


var infowindow = new google.maps.InfoWindow({ 
    content: contentString 
}); 


google.maps.event.addListener(marker, 'click', function() { 
     /* here comes something that will make my detail list visible with the marker details*/ 
}); 

,我希望把它在相同的方式工作作爲我的函數「itemtap」這是我在我的列表中使用...是這樣的:

onMyListItemTap: function(dataview, index, target, record, e, options) { 
this.setActiveItem('detalji');this.down('#back').show(); 
this.down('#detalji').setData(record.data); 
} 

回答

0

上有一個很好的例子Github爲Sencha Touch 1 ...我相信它被稱爲世界地圖。如果您解壓(該應用程序位於多個文件夾中的某個文件夾中),則可以看到Google地圖將包含多個自定義標記。這個項目對於學習非常有用,因爲它不僅顯示自定義地圖標記,而且還在標記點擊時彈出覆蓋。

我還沒有使其適應煎茶觸摸2,但它不應該太困難......這裏是一些示例代碼(多個標記已被添加後):

google.maps.event.addListener(marker, 'click', function() 
       { 
     if (!this.popup) 
        { 
      this.popup = new Ext.Panel(
          { 
      floating: true, 
      modal: true, 
      centered: true, 
      width: 500, 
      styleHtmlContent: true, 
      scroll: 'vertical', 
      items:[{ 
       xtype:'button', 
       ui:'round', 
       text:'See Country Profile', 
       handler:goToCountryWrapper, 
       scope : this 
      }, 
      (new countryOverlay(country)).overlayPanel 
      ], 
       layout: { 
       type: 'auto', 
       padding: '55', 
       align: 'left' 
      }, 
      dockedItems: [{ 
       dock: 'top', 
       xtype: 'toolbar', 
       title: country.title 
       }], 
      }); 
     }; 
     this.popup.show('pop'); 
     }); 

而且我認爲根據我對Sencha Touch 2的理解,您必須在您的地圖控制器(MyApp.map.controller文件)中放置一個監聽器....請閱讀有關參考文獻,因爲參考文獻'找到'您的標記已經定義並向該項目添加了一個監聽器。

如果您有任何進展,請發表您的發現:-)

相關問題