Skip to content

Commit

Permalink
Added a GeoJSON layer
Browse files Browse the repository at this point in the history
  • Loading branch information
fancellu committed Jan 10, 2017
1 parent 2a20a9e commit 1ebbbdc
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 4 deletions.
3 changes: 2 additions & 1 deletion example/src/main/resources/leaflet2-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
<div id="mapid" style="width:1000px;height:600px"></div>

<script type="text/javascript" src="../example-fastopt.js"></script>
<script src="southwarkpark-geojson.js" type="text/javascript"></script>
<script>
example.Leaflet2().main('mapid');
example.Leaflet2().main('mapid', southwarkpark);
</script>

</body>
Expand Down
78 changes: 78 additions & 0 deletions example/src/main/resources/southwarkpark-geojson.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
var southwarkpark={
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
-0.05085468292236328,
51.491778257971646
],
[
-0.0482797622680664,
51.493541760302776
],
[
-0.051326751708984375,
51.49493113833391
],
[
-0.0528717041015625,
51.494663953539806
],
[
-0.05626201629638672,
51.496934974371236
],
[
-0.05557537078857422,
51.49795021767351
],
[
-0.05548954010009765,
51.499660050014434
],
[
-0.05669116973876953,
51.5006752326173
],
[
-0.05853652954101562,
51.50064851757535
],
[
-0.058150291442871094,
51.49891200625809
],
[
-0.059180259704589844,
51.49845783084453
],
[
-0.0583648681640625,
51.49538534888975
],
[
-0.05845069885253906,
51.4947975461326
],
[
-0.05381584167480469,
51.49164465653034
],
[
-0.05107998847961426,
51.49165801669208
],
[
-0.05085468292236328,
51.491778257971646
]
]
}
}
]
}
10 changes: 7 additions & 3 deletions example/src/main/scala/example/Leaflet2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import scala.scalajs.js.annotation.JSExport
object Leaflet2 extends {

@JSExport
def main(el: String): LMap = {
def main(el: String, southwarkpark: js.Object): LMap = {

println(new java.util.Date)
println(JSON.stringify(southwarkpark))

val mapOptions=LMapOptions.zoom(13).center((51.505, -0.09))

Expand Down Expand Up @@ -94,8 +94,12 @@ object Leaflet2 extends {
L.marker((51.52, -0.08), MarkerOptions.icon(greenIcon)).bindPopup("I am a green leaf.").addTo(lmap)
L.marker((51.52, -0.089), MarkerOptions.icon(redIcon)).bindPopup("I am a red leaf.").addTo(lmap)

val geojson=L.geoJSON(southwarkpark)

val basemaps = literal("base"->tileLayer)
val overlays = literal("images"->layerGroup)
val overlays = literal("images"->layerGroup, "geojson"->geojson)

geojson.addTo(lmap)

L.control.layers(basemaps, overLays = overlays, ControlLayerOptions.collapsed(false).hideSingleBase(true)).addTo(lmap)

Expand Down

0 comments on commit 1ebbbdc

Please sign in to comment.