谷歌地图标记和煎茶触摸 2
Posted
技术标签:
【中文标题】谷歌地图标记和煎茶触摸 2【英文标题】:Google maps marker and Sencha touch 2 【发布时间】:2012-04-12 22:11:10 【问题描述】:我有一个使用谷歌地图的 Sencha Touch 2 应用程序。该地图将显示从带有商店的 JSON 文件加载的几个标记的位置。我的问题是,如何从我的商店中读取标记?如何使用商店中的数据生成标记?
这就是我所拥有的,它正在工作中查找,因为我有一个内联数组“neighborhoods”:
地图:
Ext.define('MyApp.view.detalleMapa',
extend: 'Ext.Map',
alias: 'widget.detallemapa',
config:
listeners: [
fn: 'onMapMaprender',
event: 'maprender'
]
,
onMapMaprender: function(map, gmap, options)
var neighborhoods = [
new google.maps.LatLng(52.511467, 13.447179),
new google.maps.LatLng(52.549061, 13.422975),
new google.maps.LatLng(52.497622, 13.396110),
new google.maps.LatLng(52.517683, 13.394393)
];
for (var i = 0; i < neighborhoods.length; i++)
var m = neighborhoods[i];
new google.maps.Marker(
position: m,
map: gmap,
draggable: false,
animation: google.maps.Animation.DROP
);
);
商店:
Ext.define('MyApp.store.itemsStore',
extend: 'Ext.data.Store',
alias: 'store.itemsstore',
requires: [
'MyApp.model.modelo'
],
config:
autoLoad: true,
model: 'MyApp.model.modelo',
storeId: 'itemsStoreId',
proxy:
type: 'ajax',
url: '/markersJsonFormat.json',
reader:
type: 'json',
rootProperty: ''
);
到目前为止一切正常,因为我在地图类中使用了数组标记“邻居”,但是如何使用商店从文件“markersJsonFormat.json”加载的数组?
有什么想法吗? 谢谢! :)
PD:这是我的应用程序:
Ext.application(
requires: [
'MyApp.view.override.detalleMapa'
],
models: [
'modelo'
],
stores: [
'itemsStore'
],
views: [
'principalTabPanel',
'navegacionView',
'itemsLista',
'detalleMapa'
],
name: 'MyApp',
launch: function()
Ext.create('MyApp.view.detalleMapa', fullscreen: true);
);
【问题讨论】:
【参考方案1】:如果有人在看,这是答案:
onMapMaprender: function(map, gmap, options)
var store = Ext.getStore('itemsstore'); // Ext.getStore('StoreId')
var count = store.getCount();
//debugger;
store.load(
scope: this,
callback: function(records)
//debugger;
this.processTweets(records);
);
,
小心,因为这会再次加载 URL 源,并在您已经加载的情况下刷新商店内容。
【讨论】:
以上是关于谷歌地图标记和煎茶触摸 2的主要内容,如果未能解决你的问题,请参考以下文章