如何在openlayers v4.6.5上用矢量创建弹出窗口

时间:2019-04-23 08:47:55

标签: javascript laravel popup click openlayers

我正在使用openlayers,我创建了许多矢量层,但是我想将click事件放在一个矢量层上。

function add_map_point(lat, lng) {
    var vectorLayer = new ol.layer.Vector({
        source:new ol.source.Vector({
            features: [new ol.Feature({
                geometry: new ol.geom.Point(ol.proj.transform([parseFloat(lng), parseFloat(lat)], 'EPSG:4326', 'EPSG:3857')),
            })]
        }),
        style: new ol.style.Style({
            image: new ol.style.Icon({
                anchor: [0.5, 0.5],
                anchorXUnits: "fraction",
                anchorYUnits: "fraction",
                src: "{{asset('marker.png')}}",
            }),
        })
    });
    map.addLayer(vectorLayer);
}

function map_points(){
    @foreach($data as $c)
        add_map_point({{$c->latitude}}, {{$c->longitude}}); 
    @endforeach    
}

1 个答案:

答案 0 :(得分:0)

请尝试添加到您的功能中

FileSystemAlreadyExistsException