Page head image

More fun with OpenLayers 3: U.S. National Parks

(0 comments)

I've made a new interactive map while I was playing with the GIS stuff again. This time to visualize the U.S. National Parks, National Monuments, National Recreational Areas, and National Seashores / Lake Shores I've visited over the last eleven years.

Compared to previous versions, Openlayers 3 is refreshingly consistent, even though the asynchronous handling of data sources makes it somewhat cumbersome at times. For example, the geographic information at Natural Earth is split into three databases: areas for large parks, lines for sea and lake shores and points for smaller parks. Also, it contains too much data, but I haven't found a way how to filter it just for the parks I want to show and unify everything in one layer. Thus, the style callback has to do that. A rather ugly hack.

Also, it is not easy to find out how to convert the shape files from Natural Earth and the U.S. Census Bureau from dBase on-disk format (is anyone here old enough to remember dBase?) to something OpenLayers can process. Fortunately, there is a free converter: GDAL comes with ogr2ogr that can even filter based on SQL queries. Recent versions support writing GeoJSON: ogr2ogr -f GeoJSON states.json cb_2014_us_state_20m.shp. Conversion to GPX is incomplete, it writes KML correctly but Viking isn't able to render it correctly, and the OpenLayers 3 KML format processor cannot cope with folders. Thus, I'm using GeoJSON.

Anyway, you can zoom and pan the map, and hovering with the mouse pointer over one of the yellow circles will pop up a small info box with the name of the park and the year(s) I visited it. It also works on mobile devices, however it may be a bit hard to successfully hit the circles on a touch screen.


U.S. National Parks, Monuments, Recreational Areas, Seashores, Lakeshores visited

Comments

There are currently no comments

New Comment

required

required (not published)

optional