除了featurecClick
工作,我什么都能得到。
我的 JS:
window.onload = function(){
var cartoDbTableName = 'sipri_import_export_map_1950_2014';
var domId = 'map';
var mapStyle = document.getElementsByClassName('map-style');
var lat = 0;
var lon = 0;
var zoomLvl = 2;
var options = {
center: [lat,lon],
zoom: zoomLvl
};
var mapObject = new L.Map(domId,options);
var layerSource = {
user_name: 'chrismp',
type: 'cartodb',
sublayers: [
{
sql: "SELECT * FROM "+cartoDbTableName+" WHERE (gwsyear <= 1950 AND gwsyear > 0)",
cartocss: mapStyle[0].innerHTML
}
]
};
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png')
.addTo(mapObject);
cartodb.createLayer(mapObject,layerSource)
.addTo(mapObject)
.on('done',function(layer){
layer.getSubLayer(0).on('featureClick', function(e, latlng, pos, data, subLayerIndex) {
console.log(e, latlng, pos, data, subLayerInde);
}).on('error',function(err){
console.log('featureClick error: '+err);
});
}).on('error',function(err){
console.log(err);
});
};
我的地图加载了样式,但是当它在一个国家/地区上空时,我的光标不会切换到手指指针,所以当我单击它时没有任何反应。是什么赋予了?