vizicities icon indicating copy to clipboard operation
vizicities copied to clipboard

Click on buildings

Open cmarfil opened this issue 7 years ago • 0 comments

Hello,

Is it possible to get information building on user click? And for example, change the color to make a selection effect?

// Buildings and roads from Mapzen (polygons and linestrings)
    var topoJSONTileLayer = VIZI.topoJSONTileLayer('https://vector.mapzen.com/osm/buildings,roads/{z}/{x}/{y}.topojson?api_key=vector-tiles-NT5Emiw', {
        interactive: true,
        style: function(feature) {
            var height;

            if (feature.properties.height) {
                height = feature.properties.height;
            } else {
                height = 10 + Math.random() * 10;
            }

            return {
                height: height,
                lineColor: '#f7c616',
                lineWidth: 1,
                lineTransparent: true,
                lineOpacity: 0.2,
                lineBlending: THREE.AdditiveBlending,
                lineRenderOrder: 2
            };
        },
        filter: function(feature) {
            // Don't show points
            return feature.geometry.type !== 'Point';
        },
        onEachFeature: function(feature, layer) {
            layer.on('click', function(layer, point2d, point3d, intersects) {
                //Get INFO of building?

                console.log('feature',feature);
                console.log('layer',layer);
                console.log('point2d',point2d);
                console.log('point3d',point3d);
                console.log('intersects',intersects);
            });
        }
    }).addTo(world);

On click, I am not able to get any information from the building and I can not access the individual styles of that building.

Thanks.

cmarfil avatar May 01 '17 20:05 cmarfil