MapClickedEvent RPC
Notifies user that map has been clicked.
Description
Event is used to nofify user about the map click. Event includes information about the click coordinates and if Ctrl was pressed at the same time.
Parameters
(* means the parameter is required)
Name | Type | Description | Default value |
---|---|---|---|
\* lonlat | Object | object with lon and lat keys as coordinates where the map was clicked | |
\* mouseX | Number | viewport mouse position x coordinate when click happened | |
\* mouseY | Number | viewport mouse position y coordinate when click happened | |
\* ctrlKeyDown | Boolean | True if Ctrl key was pressed |
RPC
Event occurs when map is clicked.
{
"lon": 423424,
"lat": 6821888,
"x": 312,
"y": 236,
"ctrlKeyDown": false
}
Event methods
getName()
Returns name of the
getLonLat()
Returns lonlat object
getMouseX()
Returns viewport mouse position x coordinate when click happened
getMouseY()
Returns viewport mouse position y coordinate when click happened
getParams()
Returns object including all the parameters, for example:
{
lon: this._lonlat ? this._lonlat.lon : null,
lat: this._lonlat ? this._lonlat.lat : null,
x: this._mouseX,
y: this._mouseY,
ctrlKeyDown: this._ctrlKeyDown
};
Examples
Mapmodule.ol catches map click and send MapCLickedEvent:
map.on('singleclick', function (evt) {
var CtrlPressed = evt.originalEvent.ctrlKey;
var lonlat = {
lon : evt.coordinate[0],
lat : evt.coordinate[1]
};
var mapClickedEvent = sandbox.getEventBuilder('MapClickedEvent')(lonlat, evt.pixel[0], evt.pixel[1], CtrlPressed);
sandbox.notifyAll(mapClickedEvent);
});