Skip to content

Commit 6cf7312

Browse files
committed
Added actions
currently with help of the javascript aler function added a way to get the WebEngine to listen on the alerts
1 parent 7c29f50 commit 6cf7312

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/main/kotlin/de/saring/leafletmap/LeafletMapView.kt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,28 @@ class LeafletMapView : StackPane() {
219219
execScript("$markerName.setIcon(${newMarker.iconName});")
220220
}
221221

222+
/**
223+
* Activates the on marker click alert
224+
*/
225+
fun addOnMarkerClick(markerName: String, icao: String){
226+
execScript("$markerName.on('click', function(e){ alert('plane,$icao')})")
227+
}
228+
229+
/**
230+
* Activates the move alert
231+
*/
232+
fun initMapDrag(){
233+
execScript("myMap.on('moveend', function (e) { alert('move,' + myMap.getCenter()); });");
234+
}
235+
236+
/**
237+
* Activates the click alert
238+
*/
239+
fun initMapClick(){
240+
execScript("myMap.on('click', function (e) { alert('click,' + e.latlng); });");
241+
}
242+
243+
/**
222244
* Draws a track path along the specified positions in the color red and zooms the map to fit the track perfectly.
223245
*
224246
* @param positions list of track positions
@@ -239,4 +261,13 @@ class LeafletMapView : StackPane() {
239261
}
240262

241263
private fun execScript(script: String) = webEngine.executeScript(script)
264+
265+
/**
266+
* Returns the WebEngine of the map
267+
*
268+
* @return the webEngine
269+
*/
270+
fun getWebEngine(): WebEngine{
271+
return webEngine
272+
}
242273
}

0 commit comments

Comments
 (0)