Skip to Content
0

Attaching Click Event to GeoMap

Feb 09, 2017 at 11:12 AM

36

avatar image

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);
}
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Albert Jose M
Feb 10, 2017 at 05:13 AM
0

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.

Share
10 |10000 characters needed characters left characters exceeded