WFS overlay popup set position multilinestring

13 views
Skip to first unread message

Ahmad

unread,
Apr 4, 2018, 4:08:56 AM4/4/18
to OpenLayers Dev
how to display a popup with the appropriate position?

 map.on('singleclick', function (evt) {
        overlayPopup.setPosition(undefined);
        closer.blur();
        var features = [];
        var layers = [];
        var feature = map.forEachFeatureAtPixel(evt.pixel, function (feature, layer) {
            features.push(feature);
            layers.push(layer);
        });

        if (layers[0] == Layer1Popup) {
            showLayer1Popup(features);
        }


    });


function showLayer1Popup(features) {
    feature = features[0];
    var coord = feature.getGeometry().getCoordinates();
    if (feature) {
        content.innerHTML = '<b>Name : ' + feature.get('name') + '</b><br><br>Phone: ' + feature.get('phone');
        overlayPopup.setPosition(coord);
    }
}
Reply all
Reply to author
Forward
0 new messages