Start a new topic

Removing exitsting POI and refreshing camera

Removing exitsting POI and refreshing camera


Hi

I'm using wikitude service to get a number of relative locations around user then on selection

I need to remove selected POI from camera and then refreshing camera with the new number of POI's locally .



I can destroy all of GeoObjects BUT cannot create new Markers because calling of new Marker(World.markerList) or            

World.markerList.markerObject.drawables.addCamDrawable(0); 

give me error called (undefined is not a function ) !!



Here is my code .. Could you send sample code for creating new markers ?!

// fired when user pressed maker in cam
    onMarkerSelected: function onMarkerSelectedFn(marker) {
        World.currentMarker = marker;

        World.currentMarkerID = marker.poiData.id ;

        for (var i = 0; i < World.markerList.length; i++) {

            if ( World.markerList.id == World.currentMarkerID)
                 World.currentMarkerINDEX = i ;
         }


      //   alert('markerlist'+ World.temp.length);

      //  AR.context.destroyAll();
      
        for (var i = 0; i < World.markerList.length; i++) {

            World.markerList.markerObject.drawables.removeCamDrawable(0);
        }

 

         World.markerList.splice(World.currentMarkerINDEX,1);


        for (var i = 0; i < World.markerList.length; i++) {

            World.markerList.markerObject.drawables.addCamDrawable(0);

           //  new Marker(World.markerList); 
        }

        World.score += 1;
        $("#score-message").html('Score: ' + World.score);

    },


























 

 

 

 

 

 

 

 

Hi Epic,

you are passing a Marker object to the Marker constructor, this won't work. I'm not 100% sure what you are trying to achieve but please take a look at the code below, it should help. If the user clicks on a Marker, all Markers will be deleted and the same Markers will be recreated. The implementation is just to give you a rough guide and should be optimized.

onMarkerSelected: function onMarkerSelectedFn(marker) {
World.markerList = ;
AR.context.destroyAll();

// Create an AR.ImageResource for the marker idle-image
World.markerDrawable_idle = new AR.ImageResource("assets/marker_idle.png");
// Create an AR.ImageResource for the marker selected-image
World.markerDrawable_selected = new AR.ImageResource("assets/marker_selected.png");
// Create an AR.ImageResource referencing the image that should be displayed for a direction indicator.
World.markerDrawable_directionIndicator = new AR.ImageResource("assets/indi.png");

for (var currentPlaceNr = 0; currentPlaceNr < World.poiData.length; currentPlaceNr++) {
var singlePoi = {
"id": World.poiData.id,
"latitude": parseFloat(World.poiData.latitude),
"longitude": parseFloat(World.poiData.longitude),
"altitude": parseFloat(World.poiData.altitude),
"title": World.poiData.name,
"description": World.poiData.description
};

/*
To be able to deselect a marker while the user taps on the empty screen,
the World object holds an array that contains each marker.
*/
World.markerList.push(new Marker(singlePoi));
}

},


 

For this to work, add following line to requestDataFromLocal function:

// request POI data
requestDataFromLocal: function requestDataFromLocalFn(centerPointLatitude, centerPointLongitude) {
...
World.poiData = poiData;
World.loadPoisFromJsonData(poiData);
}


 

I hope that helps.

Best regards,
Simon

Thanks Simon so much .. I need to remove the selected POI Itself from camera ,

I solve it using these lines of code inside onMarkerSelectedFn

        World.markerList.markerObject.drawables.removeCamDrawable(1);
        World.markerList.markerObject.drawables.removeIndicatorDrawable(0)
        World.markerList.markerObject.drawables.removeRadarDrawable(0);

 
Login or Signup to post a comment