Getting better
This commit is contained in:
parent
c791ab8ba8
commit
d714dfc49e
|
@ -40,6 +40,8 @@ Note that, unlike in **geocsv**, *THERE IS NO DEFAULT PIN*, as there is no serve
|
|||
`geocsv-lite` now experimentally displays GPX and KML formated XML, by using [leaflet-omnivore](https://github.com/mapbox/leaflet-omnivore). While `leaflet-omnivore` also parses CSV, it doesn't
|
||||
handle the CSV as richly as GeoCSV does natively, so we don't use Omnivore to parse CSV.
|
||||
|
||||
Having said that, while omnivore correctly extracts and renders boundaries from KML there's a lot of other data in KML that it doesn't (e.g. it doesn't render the requested `Style` on elements, including the rather important `BallonStyle`), so I'm not entirely satisfied and might revisit this to do my own parse/render engine.
|
||||
|
||||
## Setup
|
||||
|
||||
To get an interactive development environment run:
|
||||
|
|
|
@ -110,6 +110,16 @@ crossorigin=""/ -->
|
|||
</p>
|
||||
<div id="kml-map"
|
||||
style="height: 600px; width: 80%; border: thin solid gray;"></div>
|
||||
<h2>
|
||||
Map using inline KML
|
||||
</h2>
|
||||
<p>
|
||||
This is more limited than I would like, because of cross-site scripting
|
||||
blocks; the URL <b>must</b> be sourced from the same host as the page.
|
||||
</p>
|
||||
<div id="inline-kml-map"
|
||||
style="height: 600px; width: 80%; border: thin solid gray;">
|
||||
</div>
|
||||
<div id="doc">
|
||||
<p>
|
||||
Use this page as a crib for how to use <b>GeoCSV Lite</b> in your projects. In order
|
||||
|
@ -282,7 +292,7 @@ crossorigin=""></script -->
|
|||
geocsv_lite.core.initialise_map_element("url-map", csv_url);
|
||||
|
||||
/* Map using KML from URL */
|
||||
geocsv_lite.core.initialise_map_element("kml-map", url + "data/wild-lands/doc.kml");
|
||||
geocsv_lite.core.initialise_map_element("kml-map", url + "data/wild-lands/doc-with-balloons.kml");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -200,15 +200,22 @@
|
|||
map view identified by `k`."
|
||||
[f k data-source]
|
||||
(let [view (get-view k)]
|
||||
(if-not
|
||||
(case (:format f)
|
||||
(if-let [layer (case (:format f)
|
||||
:gpx (case (:type f)
|
||||
:url (.addTo (.gpx js/omnivore data-source) view))
|
||||
:url (.gpx js/omnivore data-source)
|
||||
:inline (.gpx.parse js/omnivore data-source))
|
||||
:kml (case (:type f)
|
||||
:url (.addTo (.kml js/omnivore data-source) view))
|
||||
:url (.kml js/omnivore data-source)
|
||||
:inline (.kml.parse js/omnivore data-source))
|
||||
:json ;; assuming geojson here, which is dodgy.
|
||||
(case (:type f)
|
||||
:url (.addTo (.kml js/omnivore data-source) view)))
|
||||
:url (.addTo (.geojson js/omnivore data-source) view)))]
|
||||
(do
|
||||
(.addTo layer view)
|
||||
;; zoom and pan the view to the bounds of the layer.
|
||||
;; map.fitBounds(runLayer.getBounds());
|
||||
(.fitBounds view (.getBounds layer))
|
||||
(n/message (str "Added " (:format f) " layer")))
|
||||
(n/error (str "Cannot yet handle " f)))))
|
||||
|
||||
(defn get-data
|
||||
|
|
Loading…
Reference in a new issue