I'm trying to apply what I'm learning from https://github.com/mhkeller/cartodb-templates/blob/master/basic/polygon-hover.html to this scenario except hover isn't triggering any info window (or any console logging for that matter). The map does render correctly. What is the problem here?:
var account = data.layergroupid.split('@')[0];
var url = 'http://'+account+'http://.cartodb.com/api/v1/map/'+data.layergroupid+'/{z}/{x}/{y}.png';
L.tileLayer(url).addTo(map)
.on('featureOver', function(e, pos, latlng, data) {
$('.leaflet-container').css('cursor','pointer');
if (data.cartodb_id != polygon.cartodb_id) {
drawHoverPolygon(data);
}
cartodb.log.log(e, pos, latlng, data);
})
.on('featureOut', function(e, pos, latlng, data) {
$('.leaflet-container').css('cursor','default');
removePolygon();
})
.on('error', function(err) {
cartodb.log.log('error: ' + err);
});
var polygon = {};
var polygon_style = {
color: "white",
weight: 2,
opacity: 1,
fillOpacity: .45,
fillColor: "white",
clickable: false
}
function drawHoverPolygon(data){
removePolygon();
polygon = new L.GeoJSON(JSON.parse(data.geometry), {
style: polygon_style
}).addTo(map);
polygon.cartodb_id = data.cartodb_id;
}
function removePolygon(){
map.removeLayer(polygon);
polygon.cartodb_id = null;
}
Aucun commentaire:
Enregistrer un commentaire