-1
當用戶點擊點(Cartodb圖層)時,我只想繪製一個圓圈(Google.Maps.Circle),也許最後繪製的圓圈可能會自動刪除。這是我的代碼:只需點擊一個圓點 - Google Maps Api - Cartodb
//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']);
});
非常感謝!