Gonzalo Quiroga
Gonzalo Quiroga

Reputation: 1

OpenLayers 3 can´t use Tile and Vector layer class

Im having this problem. Im making a map with openlayers 3. I have a layerswitcher with a group of tile class layers, and it works perfectly until I try to remark with a mousover the diferent layers, so the user can know that he can click on them to get feature info. Something like this https://openlayersbook.github.io/ch06-styling-vector-layers/example-08.html.

The problem is I need the layers in ol.layer.Vector class, and i was using ol.layer.Tile, so I had to update the ol3 that i was using v3.7.0 to the v3.16.0, and if I use only ol.layer.Vector class works, but I need both of them, and using both, the layers appear, but such for a moment.. then the background covers it.. like a load problem. I thought it was a ccs problem, but no, its the new js.

Summarizing, my problem is that the layers in tile class overlap with the layers in vector class, and the map only show me one, or none. If anybody can help me I will be greatful. Thanks!

Upvotes: 0

Views: 159

Answers (1)

ahocevar
ahocevar

Reputation: 5648

The example you linked above only works with OpenLayers < v3.7.0, because it uses ol.FeatureOverlay. You have to replace that with ol.layer.Vetcor. See the v3.7.0 release notes for upgrade instructions. Once you have that, it should be easy to add tile layers. Just make sure that you add them to the map before you add a vector layer. Something like

  var map = new ol.Map({
    target: 'map',
    layers: [
      new ol.layer.Tile({
        source: new ol.source.OSM()
      }),
      countries
    ],
    view: view
  });

Upvotes: 0

Related Questions