2

Using OpenLayers 2, I want to have an offline baselayer, that is loaded from a KML or GEOJSON file. I am successfully able to do this if I first load a baselayer from google maps. For example, this works fine and am able to properly switch between the two layers:

var googlePhys = new OpenLayers.Layer.Google(
      "Google Physical",
      {type: google.maps.MapTypeId.TERRAIN});
var worldGEOJSON = new OpenLayers.Layer.Vector("GeoJSON", {
projection: "EPSG:3857",
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
    url: "maps/test.geojson",
    format: new OpenLayers.Format.GeoJSON()
}),
isBaseLayer:true,
visibility:true
});

map.addLayers([googlePhys, worldGEOJSON]);

However, changing just one line, this does not work:

map.addLayers([worldGEOJSON, googlePhys]);

I can switch back and forth between the two and the the google layer works fine, but the geojson layer never displays. Just a blank white screen. I have tried changing the style of the geojson layer and that works fine in the first example, but not the second. Any thoughts?

1
  • Any more info on this?
    – Jim
    Nov 25, 2015 at 21:16

0

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.