Start a new topic

object on click runs without click

object on click runs without click


I did this

 

var openInfo = function (marker) {

 

return function()

{

var id = marker.id;

document.location = "architectsdk://clickOnObject?param="+id;

}

 

};

 

Now it works, thank you Martin.

Hi Luca,

Check marker.js, line 76: onClick: openInfo(this)

You are executing the openInfo function when the object is initialized (the (...) indicate that the function is executed).

You have two options to solve this:

1.) Leave the assignment to onClick as it is, and change openInfo in a way that it returns a function that is executed when the marker is clicked, similar to the example below:

var openInfo = function(parameters){

    return function(){

            // do stuff

    };

}

2.) Leave openInfo as it is and change the assignment of onClick to not call, but only reference the function:

onClick: openInfo

 

I suggest you to study the difference between referencing and calling functions in JavaScript to get a full understanding of the difference. 

Best,

Martin

Hi everyone.

I used this code to execute a function on click on a marker, but click event is run on AR loading for each POI loaded.

 

In attachment there are mutiplepois2.js and marker.js
Login or Signup to post a comment