1

I have problem with this.

if I use this

   function Add_Polygon() {
     ...
       bk_map_poly_feature.setStyle(my_style);   
     ...
    }

function my_style() {
    var bk_map_polygon_style = new ol.style.Style({
    text: new ol.style.Text({
        text: map.getView().getZoom() > 20 ? 'area-1' : '',
        offsetY: 10,           
    })
})
    return bk_map_polygon_style;
}

It is OK. It works. But I want to area name as parameter like this.

function Add_Polygon() {
...
bk_map_poly_feature.setStyle(my_style('area-1'));
...
}

function my_style(area_name) {
var bk_map_polygon_style = new ol.style.Style({
    text: new ol.style.Text({
        text: map.getView().getZoom() > 20 ? area_name : '',
        offsetY: 10,
    })

})
return bk_map_polygon_style;

}

It gives me an error.

TypeError: Cannot read property 'getView' of undefined

How can I solve this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.