Leaflet: Add inverse of L.latLngBounds.toBBoxString

Created on 5 Mar 2014  ·  3Comments  ·  Source: Leaflet/Leaflet

In my app I serialize and deserialize bbox strings. This coffee code helps me out:

L.latLngBounds.fromBBoxString = L.latLngBounds.fromBBoxString or (bbox) ->
  [west, south, east, north] = bbox.split(',').map(parseFloat)
  new L.LatLngBounds(new L.LatLng(south, west), new L.LatLng(north, east))

Imho this functionality could fit in Leaflet core

Most helpful comment

It's no less opinionated than toBBoxString(), but certainly more difficult to implement properly (missing parameters, max-min order etc). Right now the class lacks symmetry, which is usually a good thing to have.

All 3 comments

:-1: this should stay in helpers, not in core. BBOX encoding is opinionated, constructor bloat is bad, and this is easy to implement outside of core.

Agreed.

It's no less opinionated than toBBoxString(), but certainly more difficult to implement properly (missing parameters, max-min order etc). Right now the class lacks symmetry, which is usually a good thing to have.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

apachemaven picture apachemaven  ·  34Comments

dankarran picture dankarran  ·  39Comments

tannerlinsley picture tannerlinsley  ·  28Comments

MuellerMatthew picture MuellerMatthew  ·  70Comments

colm-quinn picture colm-quinn  ·  30Comments