aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2020-03-27 18:53:47 +0100
committerRobert Jaros <rjaros@finn.pl>2020-03-27 18:53:47 +0100
commit4f111976f842b9a63363181ad2182091bb810c46 (patch)
tree1c8d8edd093bc0ab7260e929ed08ce8e0cdd7473 /kvision-modules
parentb608521b89063e39632a3462a0585184be0dbbf5 (diff)
downloadkvision-4f111976f842b9a63363181ad2182091bb810c46.tar.gz
kvision-4f111976f842b9a63363181ad2182091bb810c46.tar.bz2
kvision-4f111976f842b9a63363181ad2182091bb810c46.zip
Fix support for default images (markers) in the maps module.
Diffstat (limited to 'kvision-modules')
-rw-r--r--kvision-modules/kvision-maps/src/main/kotlin/pl/treksoft/kvision/KVManagerMaps.kt11
-rw-r--r--kvision-modules/kvision-maps/src/main/kotlin/pl/treksoft/kvision/maps/Maps.kt6
2 files changed, 16 insertions, 1 deletions
diff --git a/kvision-modules/kvision-maps/src/main/kotlin/pl/treksoft/kvision/KVManagerMaps.kt b/kvision-modules/kvision-maps/src/main/kotlin/pl/treksoft/kvision/KVManagerMaps.kt
index 5fb39d42..b5925901 100644
--- a/kvision-modules/kvision-maps/src/main/kotlin/pl/treksoft/kvision/KVManagerMaps.kt
+++ b/kvision-modules/kvision-maps/src/main/kotlin/pl/treksoft/kvision/KVManagerMaps.kt
@@ -21,6 +21,8 @@
*/
package pl.treksoft.kvision
+import pl.treksoft.kvision.utils.obj
+
internal val kVManagerMapsInit = KVManagerMaps.init()
/**
@@ -34,5 +36,14 @@ internal object KVManagerMaps {
internal val leaflet = require("leaflet/dist/leaflet.js")
+ init {
+ leaflet.Icon.Default.imagePath = "./"
+ leaflet.Icon.Default.mergeOptions(obj {
+ iconRetinaUrl = require("leaflet/dist/images/marker-icon-2x.png")
+ iconUrl = require("leaflet/dist/images/marker-icon.png")
+ shadowUrl = require("leaflet/dist/images/marker-shadow.png")
+ })
+ }
+
internal fun init() {}
}
diff --git a/kvision-modules/kvision-maps/src/main/kotlin/pl/treksoft/kvision/maps/Maps.kt b/kvision-modules/kvision-maps/src/main/kotlin/pl/treksoft/kvision/maps/Maps.kt
index cf68fd2e..cb98fb8a 100644
--- a/kvision-modules/kvision-maps/src/main/kotlin/pl/treksoft/kvision/maps/Maps.kt
+++ b/kvision-modules/kvision-maps/src/main/kotlin/pl/treksoft/kvision/maps/Maps.kt
@@ -35,12 +35,14 @@ import pl.treksoft.kvision.utils.obj
* @param lat initial latitude value
* @param lng initial longitude value
* @param zoom initial zoom
+ * @param showMarker show marker in the initial position
* @param classes a set of CSS class names
*/
open class Maps(
val lat: Number,
val lng: Number,
val zoom: Number,
+ val showMarker: Boolean = false,
classes: Set<String> = setOf(),
init: (Maps.() -> Unit)? = null
) : Widget(classes) {
@@ -63,6 +65,7 @@ open class Maps(
this.center = arrayOf(lat, lng)
this.zoom = zoom
})
+ KVManagerMaps.leaflet.marker(arrayOf(lat, lng)).addTo(jsMaps)
KVManagerMaps.leaflet.tileLayer(
"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
obj {
@@ -86,10 +89,11 @@ fun Container.maps(
lat: Number,
lng: Number,
zoom: Number,
+ showMarker: Boolean = false,
classes: Set<String> = setOf(),
init: (Maps.() -> Unit)? = null
): Maps {
- val maps = Maps(lat, lng, zoom, classes, init)
+ val maps = Maps(lat, lng, zoom, showMarker, classes, init)
this.add(maps)
return maps
}