MarkerClickEvent RPC
Notifies that map marker has been clicked.
Description
Used to notify the user about the id of the clicked marker.
Parameters
(* means the parameter is required)
Name | Type | Description | Default value |
---|---|---|---|
\* id | String | id of the clicked marker |
RPC
Event occurs when map marker is clicked.
{
"id": "REPORT_MARKER"
}
Event methods
getName()
Return name of the event.
getID()
Returns id of the clicked marker.
getParams()
Returns id of the marker as an object as follows:
{
"id": "RPC_MARKER"
}
Examples
MarkersPlugin catches marker click and sends MarkerClickEvent:
/**
* Creates a marker layer
* @private
*/
_createMapMarkerLayer: function() {
var me = this,
markerLayer = new OpenLayers.Layer.Vector('Markers');
markerLayer.events.fallThrough = true;
// featureclick/nofeatureclick doesn't seem to be emitted, so working around that
markerLayer.events.register('click', this, function(e) {
if(me._waitingUserClickToAddMarker) {
// adding a marker, handled in __mapClick()
return true;
}
// clicking on map, check if marker is hit
if (e.target && e.target._featureId) {
me.__markerClicked(e.target._featureId);
}
return true;
});
this.getMap().addLayer(markerLayer);
this.raiseMarkerLayer(markerLayer);
return markerLayer;
},
/**
* Called when a marker has been clicked.
* @method __markerClicked
* @private
* @param {String} markerId which was clicked
*/
__markerClicked: function(markerId) {
var sandbox = this.getSandbox();
var clickEvent = sandbox.getEventBuilder('MarkerClickEvent')(markerId);
sandbox.notifyAll(clickEvent);
},