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
Hywel Bennett
08/19/2021, 1:32 PM
Define the argument as type
dynamic
and use the
js()
function, e.g.
js("{}")
to generate the object?
t
turansky
08/19/2021, 2:45 PM
No
dynamic
please 🙂
âž• 1
turansky
08/19/2021, 2:50 PM
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
Marius Ailinca
08/19/2021, 3:59 PM
Wow! jsObject ... kotlin-wrappers, didn't know about it. Thanks a lot Victor!!!