Skip to Content
avatar image
Former Member

Attaching Click Event to GeoMap

Hi everyone,
I need to attach a 'click' event to geomap control, on press of a button. I have used the attachClick function in geomap control. Even after attaching the event, the target function is not getting executed.

ie,

In the given snippet, even after attaching the click-event "onClickMap", the function is not invoked when click event occurs on geomap.

In View :-

<vbm:GeoMap id="map">...</vbm:GeoMap>
.
.
.
.
<Button text="Attach Click" press="onAddCordinates"></Button>

In controller :-

onClickMap: function(oEvent) {
	var position = oEvent.getParameter("pos");
	console.log(position);
}

onAddCordinates: function(evnt) {
	this.getView().byId("map").attachClick(this.onClickMap);
}
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Feb 10, 2017 at 05:13 AM

    I solved the issue with an alternate logic. The attachClick function didn't work. So I defined the event in click event in the geomap control.

    In View :-

    <vbm:GeoMap id="map" click="onClickMap">...</vbm:GeoMap>
    .
    .
    .
    .
    <Button id="addBtn" text="Attach Click" press="onAddCordinates"></Button>

    In controller :-

    onClickMap: function(oEvent) {<br>if(!this.getView().byId("addBtn").getEnabled()){
    	var position = oEvent.getParameter("pos");
    	console.log(position);
       }
    }
    
    onAddCordinates: function(evnt) {
    	evnt.getSource().setEnabled(false);
    }

    Since I had to disable and enable the button for my use case, I used that property of the button to enable the click-event function logic.

    Add comment
    10|10000 characters needed characters exceeded