当用户单击点(Cartodb 层)时,我只想绘制一个圆圈(Google.Maps.Circle),也许最后绘制的圆圈可以自动删除。这是我的代码:
//CARTODB layer
var cartoLayer = cartodb.createLayer(map, {
user_name: 'username',
type: 'namedmap',
named_map: {
name: "namemap",
layers: [{
layer_name: "t",
interactivity: "cartodb_id, name, coordinateuncertaintyinmeters, class"
}]
}
});
cartoLayer.addTo(map)
.done(function(layer) {
layer.getSubLayer(0).setInteraction(true);
layer.setZIndex(9);
// on mouseover
layer.getSubLayer(0).on('featureOver', function(e, pos, pixel, data) {
// print data to console log
console.log("Event #" + data.cartodb_id + ", Name " + data.name + ", Clase: " + data.class+ ",Incertidumbre(m.) " + data.coordinateuncertaintyinmeters );
});
layer.on('featureClick', function(e, latlng, pos, data) {
//DRAW A CIRCLE WHEN CLICK ON ONE POINT
circle = L.circle(latlng, data.coordinateuncertaintyinmeters, {
color: 'red',
fillColor: '#f03',
fillOpacity: 0.5
}).addTo(map);
});
// show infowindows on click
cdb.vis.Vis.addInfowindow(map, layer.getSubLayer(0), ['cartodb_id','name', 'coordinateuncertaintyinmeters', 'class']);
});
非常感谢!