cancel
Showing results for 
Search instead for 
Did you mean: 

Attaching Click Event to GeoMap

Former Member
0 Kudos

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);
}

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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.

Answers (0)