13

I have a map which overlays Open Street Map data on imagery for Pennsylvania. As a baselayer to the roads (and eventually other layers) I have two baselayers - Blue Marble NG and USGS EROS 1ft imagery. I would like to be able to combine these two layers into a single base map object that switches automatically as the user zooms in since it makes no sense to view the 1ft imagery for the whole state or the Blue Marble imagery when you are zoomed in.

Ideally I'd like to do this on the client side as I'm pulling the imagery from two different sites.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Ian Turton
  • 81,417
  • 6
  • 84
  • 185
  • There is a broken link in this question that has been pointed out at http://gis.stackexchange.com/questions/173775/how-to-extract-specific-information-from-grib-files#comment260374_173775 It is a shame a comment was not made here instead to alert you earlier. – PolyGeo Dec 15 '15 at 11:12

2 Answers2

17
  1. Add 2 base layers to the map
  2. Subscribe to the map's zoomend event
  3. Check the zoom level and just switch the base map for your user

Here's a sample page with an event handler for zoomend - http://www.openlayers.org/dev/examples/events.html.

Vadim
  • 3,971
  • 2
  • 29
  • 42
  • 1
  • @iant, Any chance I could get you to paste a snippet of you code? I'm trying to make this happen, and it's just buggy. Thanks! –  Nov 23 '12 at 21:48
  • There is a broken link in this answer that has been pointed out at http://gis.stackexchange.com/questions/173775/how-to-extract-specific-information-from-grib-files#comment260374_173775 It is a shame a comment was not made here instead to alert you earlier. – PolyGeo Dec 15 '15 at 11:13
  • -1 for a single broken link in a 5-year old answer? Seriously? I don't care about the points, really, but I can't imagine the admins are now asking everyone to maintain links to external references. Note that the answer in bullets 1,2,3 is complete and API links still work. If reader needs to find a sample I trust they can find it on their own. OL has changed and moved on so much in last 5 years. – Vadim Dec 15 '15 at 21:25
0

Another way... using opacity control

Try this example https://github.com/openlayers/ol2/blob/master/examples/layer-opacity.html

a combo of USGS_EDC_Elev_NED_3 (Shaded Relief) and Topo Maps with opacity control

Works quite well.

Mapperz
  • 49,701
  • 9
  • 73
  • 132
  • Not quiet the effect I was trying for but a nice example. – Ian Turton Sep 20 '10 at 20:00
  • There is a broken link in this answer that has been pointed out at http://gis.stackexchange.com/questions/173775/how-to-extract-specific-information-from-grib-files#comment260374_173775 It is a shame a comment was not made here instead to alert you earlier. – PolyGeo Dec 15 '15 at 11:11
  • update the link to github source – Mapperz Dec 15 '15 at 16:49