Open-Historical-Map-Labs / openhistoricaltiles

First iteration of vector tiles from OHM Planet data
BSD 2-Clause "Simplified" License
3 stars 0 forks source link

TimeSlider demo, create and implement URL hash control I/O #38

Closed gregallensworth closed 5 years ago

gregallensworth commented 5 years ago

Expanding on the MBGL TimeSlider control demonstration, built in #33

Implement on this demo, a new map control which will write URL params of the map's state, and on startup will read URL params to set the map's state.

gregallensworth commented 5 years ago

MBGL portion working. The MBGL demo now includes two new TimeSlider controls: UrlHashWriter and UrlHashReader

https://github.com/OpenHistoricalMap/openhistoricaltiles/tree/gh-pages/mbgl-control-timeslider#additional-tools-urlhashreader-and-urlhashwriter

These do as expected: Reader will do a one-time apply of URL params to set the map state, and Writer will sit and watch the map and slider every second and update URL params as necessary.

Note that this is new ground here in some ways. URL params have a mostly de-facto standard of #12/34.567/-123.456 as being zoom, latitude, longitude. However, there is no standard for extending beyond these, so my new addition /date,mindate-maxdate is somewhat ad-hoc because it seems good and readable and extensible. We may be compelled to change this as needs and date-representation standards develop.

gregallensworth commented 5 years ago

Leaflet wrapper now working:

https://openhistoricalmap.github.io/openhistoricaltiles/leaflet-control-mbgltimeslider/demo/#16.6/40.8217108/-73.9119449/1980,1970-2000

URL params are loaded into initial state, then tracked ongoing.

Again, a thin wrapper over the existing MBGL controls so as not to duplicate the logic. If Leaflet ever gets better support for vector tiles, maybe it would make sense to rewrite all three items (TimeSlider, UrlHashReader, UrlHashWriter) from scratch to those native libraries... while also keeping their URL spec implementations in sync. But at this time, MBGL is the only game in town so it's what we're using.