简体   繁体   中英

OpenLayers 3: How to change/set the style of vector map

I am trying to remove all of the lines from an indoor vector map. Im not sure how to do this using styles. Can someone guide me on this?

here is the code of how i set the map up:

var vector = new ol.layer.Vector({
    source: new ol.source.Vector({
        url: MAPS_URL + 'map.kml',
        format: new ol.format.KML()
    })
});

var map = new ol.Map({
  layers: [vector],  
  target: 'floormap',
  interactions: ol.interaction.defaults({mouseWheelZoom:false}),
  view: new ol.View({
      center: [0, 0],          
      zoom: 15,
      minZoom: 15,
      maxZoom: 18
    })    
}); 

do i have to use the foreachfeature method to loop through the features and set the style individually or is there a way to set a global style on the map? I think vectors take on a default style when none is defined, how do i create a style with no stroke or fill, and then set that as the style for the vector map?

thank you

here is the solution, gotten from the link that Jonatas provided

var stroke = new ol.style.Stroke({
    color: 'rgba(255, 204, 0, 0)',
    width: 0,
});

var style = new ol.style.Style({
    stroke: stroke
});


vector = new ol.layer.Vector({
    source: new ol.source.Vector({
        url: MAPS_URL + maps[map_id],
        format: new ol.format.KML({
            extractStyles: false
        })
    }),
    style: style
});        

map.addLayer(vector);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM