Hi! Any idea how I can write this js in Kotlin? : ...
# javascript
m
Hi! Any idea how I can write this js in Kotlin? :
Copy code
var map = new H.Map(
{
center: {lat: 40.745390, lng: -74.022917},
zoom: 13.2
});
center is not properly initialized. I tried defining an interface for center (IPoint) and pass an object:IPoint to the constructor but it doesn't work. Tried to implement the interface in a class and still doesn't work. How to I pass a json anonymous object from kotlin to js? Thank you!
h
Define the argument as type
dynamic
and use the
js()
function, e.g.
js("{}")
to generate the object?
t
No
dynamic
please 🙂
âž• 1
Copy code
external interface Location {
    var lat: Double
    var lng: Double
}

external interface MapOptions {
    var center: Location
    var zoom: Double
}

// your module config
external class Map(options: MapOptions)

fun main() {
    val map = Map(
        options = jsObject {
            center = jsObject { lat = 40.2, lng = -74.1 },
            zoom = 13.2,
        }
    )
}
🙌 1
m
Wow! jsObject ... kotlin-wrappers, didn't know about it. Thanks a lot Victor!!!
t
And
js {}
if you want
dynamic
as result