Skip to content

Click on buildings #212

Description

@cmarfil

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions