Tôi muốn sử dụng Leaflet.js API với Sencha cảm ứng 2.3.1 và leaflet.js cho lỗi này:Sencha Touch và Leaflet.js API
Uncaught Error: Map container not found.
Các liên kết này có trong index.html
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
Đây là mã mainview tôi:
Ext.define('App.view.Main', {
extend: 'Ext.Container',
xtype: 'main',
requires: [
'App.view.MapView',
],
config: {
layout: 'card',
items: [
{
itemId: 'mapview',
xtype: 'mapview',
id : 'map'
}
]
}
});
Đây là 'App.view.MapView' mã:
012.351.Ext.define("App.view.MapView", {
extend: 'Ext.Container',
requires: ['Ext.device.Geolocation'],
xtype: 'mapview',
initialize: function(){
var map = L.map('map').setView([47.36865, 8.539183], 13);
var layer = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
map.on('click', function() {
console.log('Click-Event on map/Time: ' + Date.now());
});
},
});
Tôi đang làm gì sai? Hãy giúp tôi.
Vì vậy, có vẻ như bộ chọn id không hoạt động ... Lạ lùng. Tôi tự hỏi tại sao. –
Tôi đang cố gắng làm như thế nào là câu trả lời, nhưng bản đồ không xuất hiện. Làm thế nào tôi có thể sửa lỗi này? – Tenz