Skip to content

Commit

Permalink
Added actions
Browse files Browse the repository at this point in the history
currently with help of the javascript aler function
added a way to get the WebEngine to listen on the alerts
  • Loading branch information
N1k145 committed Dec 7, 2017
1 parent 7c29f50 commit 6cf7312
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/main/kotlin/de/saring/leafletmap/LeafletMapView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,28 @@ class LeafletMapView : StackPane() {
execScript("$markerName.setIcon(${newMarker.iconName});")
}

/**
* Activates the on marker click alert
*/
fun addOnMarkerClick(markerName: String, icao: String){
execScript("$markerName.on('click', function(e){ alert('plane,$icao')})")
}

/**
* Activates the move alert
*/
fun initMapDrag(){
execScript("myMap.on('moveend', function (e) { alert('move,' + myMap.getCenter()); });");
}

/**
* Activates the click alert
*/
fun initMapClick(){
execScript("myMap.on('click', function (e) { alert('click,' + e.latlng); });");
}

/**
* Draws a track path along the specified positions in the color red and zooms the map to fit the track perfectly.
*
* @param positions list of track positions
Expand All @@ -239,4 +261,13 @@ class LeafletMapView : StackPane() {
}

private fun execScript(script: String) = webEngine.executeScript(script)

/**
* Returns the WebEngine of the map
*
* @return the webEngine
*/
fun getWebEngine(): WebEngine{
return webEngine
}
}

0 comments on commit 6cf7312

Please sign in to comment.