Start a new topic

POI Touched Callback

POI Touched Callback


I am using the wikitude SDK for an iOS app. I have POI's placed as geoobjects and want to be able to display additional information about them when they are tapped. Due to the need for interactivity I need to know which POI was tapped on the Obj-C side of things rather than JS. My question therefore is how to call an Obj-C function when the JS senses that one of the POI's has been tapped. It will also need to pass which object was tapped and therefore needs to be able to accept arguments. Is this possible and if so, how?



Did you check the Native Detail screen sample - which explains the communication between the native and the js part.



I have looked at that sample. The code I have currently looks like this:

var markerObject = new AR.GeoObject(markerLocation, {
drawables: {cam: , radar: radarImage },
onClick: self.poiTapped(poiData.assetID)

The problem is that the onClick function is not getting called when the geoObject is tapped. What is more confusing is that the poiTapped function does get called when the AR view is loading. It gets called once for each POI that exists in the AR view, but will never get called again. The POI tapped function looks like this:

poiTapped: function(id){"clicked id: " + id);
document.location = "architectsdk://event?action=poiTapped&id=" + id;


Any ideas would be greatly appreciated!

Hi there!


I think it's more a general JS question rather than a Wikitude AR SDK "issue".

Using closures should solve the issue, try something like this (code snippet untested though)



var markerObject = new AR.GeoObject(markerLocation, {
drawables: {cam: , radar: radarImage },
onClick: function(assetId) {
return function() {"clicked assetId: " + assetId); 
// note that 'this' refers to the clicked AR.GeoObject in this context
document.location = "architectsdk://event?action=poiTapped&id=" + assetId;


Best regards,
Login or Signup to post a comment