Start a new topic
Solved

avoiding the stacking of POIs

avoiding the stacking of POIs


Renso,

Thanks for following my posts. I am glad that I am able to help someone, but the thanks should really go to Andreas and Alexander.

Now, I am facing another problem of disappearing Radar, which I am trying to figure out! The radar seems to show up behind all the POI markers for a second, and disappears. But that is a topic for another post!

K. Ramesh
 

hi, 

Ramesh, I have been following your post because everything i tryed fail but thanks to you persistence i fanally got it to worked, thanks againg. :)

Hi Andreas,

Thanks for the response. I understood what you are saying, finally! All along I was trying to set the altitude as '0' when I was creating the singlePoi obj and trying to increase it later using the clustering code. Finally it dawned on me that you are talking about the setLocation call on the architectView. Once I realized my mistake and set it, it started working. Now the markers are showing up at different heights. Thanks to you and Alexander.

K. Ramesh

Hi there!

Besides the hints of Alexander please also ensure you pass altitude '0' information to architectView on Location updates. Otherwise your altitude clustering is not working as you expect it - as states in page 1 of this post already.

Kind regards,
Andreas

 

Hi there,

I was a little busy lately :)

I checked your code and found something:
ert shows up corretly and the altitude number keeps increasing by 500. But the marker remains at the same height!

     markerObject = new AR.GeoObject(markerLocation, {
            drawables: {
                cam: ,
                indicator: this.directionIndicatorDrawable
            }
        });
        if (this.poiData.title.indexOf('Pai') != -1) {
            markerObject.onClick = function() {
                alert(markerObject.locations.altitude);
                markerObject.locations.altitude = markerObject.locations.altitude+500;
            };
        }

there is no locations array. Try to replace the highlighted lines with :

alert(markerLocation.altitude);
markerLocation.altitude = markerLocation.altitude + 50;

That should do the trick.

regards,

Alexander

 

Hello Andreas,

Can you guys help out? Alexander gave some good leads on the issue. Apparently it is working for him. But whatever I have tried, it doesn't seem to work for me. I have provided enough details on the various thigs I have tried. Anything else I need to try to make this altitude thing work correctly?

Why is it so difficult to get answers from Wikitude support team? I know I am still on the trial version, but without getting the issues sorted out, how can I decide to buy the paid version? Please help out.

K. Ramesh

Hi Alexander,

Do you have any feedback based on my latest reply? I know I am bothering you, but I am stuck and no one else,  including Wikitude support team, seem to have an answer. Please help.

Thx

K. Ramesh

I added the below code in the markerObject creation where I am increasing the altitude on a click. Even this is not working! The alert shows up corretly and the altitude number keeps increasing by 500. But the marker remains at the same height!

     markerObject = new AR.GeoObject(markerLocation, {
            drawables: {
                cam: ,
                indicator: this.directionIndicatorDrawable
            }
        });
        if (this.poiData.title.indexOf('Pai') != -1) {
            markerObject.onClick = function() {
                alert(markerObject.locations.altitude);
                markerObject.locations.altitude = markerObject.locations.altitude+500;
            };
        }

Hi,

you could try to work it out step by step.

First take the marker.js an do

var markerLocation = new AR.GeoLocation(poiData.latitude, poiData.longitude, 250);

if this works then you can try the next change like :

var markerLocation = new AR.GeoLocation(poiData.latitude, poiData.longitude, 0);

markerLocation.altitude = 250;

if this works then you can set

markerLocation = poiData.location;

poiData.location.altitude = 250;

and so on, try to make as little change as possible from the original to see where the problem lies.

kind regards,

Alexaner

Hi Alexander,

Sorry to bother you again. I had already done the changes as suggested by you and had done debugging also. For some reason it doesn't seem to work for me. I have tried hard coding the altitude for one of the POIs, even that is not working.

            for (var i=0; i<World.placeGeoObjects.length; i++) {
            //go through all items in each cluster
                for (var j=0; j<World.placeGeoObjects.places.length; j++) {
                    singlePoi = World.placeGeoObjects.places;
                    // the singlePoi altitude is originally 0
                    // it will be increased by 250 for each item remaining in the cluster
                    try{
                        singlePoi.altitude = World.getNewAltitude(singlePoi, j);
                        singlePoi.location.altitude = singlePoi.altitude;
                    }catch(e){
                        alert(e.message);
                    }
                    
                    if (singlePoi.title.indexOf('Blah Blah') != -1) {
                        singlePoi.location.altitude = 1500;  ===> hard coding the altitude for one POI
                    }
                    World.markerList.push(new Marker(singlePoi));
                }
            }

I have done the marker.js change also through this line: var markerLocation = poiData.location;. This is slightly different than what you had suggested but it should be fine. Is there something else I could be missing. I read somewhere in the forum that the accuracy that is received by onLocationChanged matters for altitude setting. Does it?

I really appreciate your help. Thanks

K. Ramesh

Hi There,

There need to be two changes :

First:

//DO the clustering

           World.placeGeoObjects  = ClusterHelper.createClusteredPlaces(55, World.userLocation, World.markerListUnclustered);

Loop through the cluster

          singlePoi=World.placeGeoObjects.places;

          singlePoi.altitude = World.getNewAltitude(singlePoi, j); ==> getNewAltitude method has the logic posted by you to calculate the height

          //You need to set the altitude of the GeoObject  :      

          singlePoi.location.altitude = World.getNewAltitude(singlePoi, j);

          World.markerList.push(new Marker(singlePoi)); ====> This is where finally the Marker is created and added to the markerList

end loop

 

Second:

you have to change the marker.js File

there is a line :

var markerLocation = new AR.GeoLocation(poiData.latitude, poiData.longitude, poiData.altitude); (Line 16 of the marker.js Sample phonegap app)

This line is now obsolete an can be deleted because your poiData now has a poiData.location Geolocation Object

AND:

 var markerObject = new AR.GeoObject(markerLocation, {   (Line 54 of marker.js phonegap sample)

needs to be changed to

 var markerObject = new AR.GeoObject(poiData.location, {   (Line 54 of marker.js phonegap sample)

I hope you get it running. If not you should try to do some debugging. Pass some fixed values of height to see if it works and use colsole.log to debug output your caculations to see if the right vales get returned.

kind regards,

Alexander

Hi Alexander,

Thanks again. I am still doing something wrong and it is not working for me. Let me explain my code flow:

Loop through json items from webservice

           create singlePoi per item

           singlePoi.location = new AR.GeoLocation

           World.markerListUnclustered.push(singlePoi);

end loop

           //DO the clustering

           World.placeGeoObjects  = ClusterHelper.createClusteredPlaces(55, World.userLocation, World.markerListUnclustered);

Loop through the cluster

          singlePoi=World.placeGeoObjects.places;

          singlePoi.altitude = World.getNewAltitude(singlePoi, j); ==> getNewAltitude method has the logic posted by you to calculate the height

          World.markerList.push(new Marker(singlePoi)); ====> This is where finally the Marker is created and added to the markerList

end loop

So, where exactly in the above sequence should I be setting the height so that it works? Thanks

K. Ramesh

 

 

Hi there,

you should assign a height right away.(otherwise the objects might jump)  When you use:

singlePoi.location = new AR.GeoLocation(singlePoi.latitude, singlePoi.longitude, singlePoi.height);

and additionally you can change the height afterwards within the dataFromWebservice.js easily using a call like

World.markerList.poiData.location.altitude = singlePoi.altitude;

And I would suggest to put the clustering function into the locationupdate area as well :

if (!World.alreadyRequestedData) {
             if (Tour.id > 0){
                World.requestDataFromServer(lat, lon);
                World.alreadyRequestedData = true;}
            }
        else
        {

         Do The Clustering

}

This way when you move around and come closer toward the POIs they get reclustered if necessary.

good luck !

Alexander

 

Hi Alexander,

Thanks for the quick response.

One question: are you saying all the Markers need to be created first, added to World.markerList and then the altitude has to be assigned? If yes, wouldn't that created a little jump in the UI since the markers would already be visible in the UI before the altitude is changed? Also, I am maintaining the unclustered singlePOIs in a separate array through World.markerListUnclustered.push(singlePoi); for height calculation later.

I will give your suggestion a try and let you know how it goes.

K. Ramesh

Hi there,

I had the same probelm :). You can solve it when you create a GeoLocation first and pass it the to the marker afterwards:
           
                singlePoi.latitude = parseFloat(poiData.pois.lat);
                singlePoi.longitude = parseFloat(poiData.pois.lng);
                singlePoi.altitude = 0;
               
                 singlePoi.location = new AR.GeoLocation(singlePoi.latitude, singlePoi.longitude, 0);
                 World.markerList.push(new Marker(singlePoi));
               
If you do it this way you have to change the marker.js to use the location

marker.js:
    var markerObject = new AR.GeoObject(poiData.location, {
        drawables: {
            cam:
            //indicator: this.directionIndicatorDrawable
        }
    });

then you can change the altitude by setting:

  World.markerList.poiData.location.altitude = heightValue;

Another thing that you might want to implement is :

var poi1 = new AR.GeoLocation(singlePoi.latitude,singlePoi.longitude);
                 dist = poi1.distanceToUser();
                    if (!isNaN(dist)){
                        singlePoi.distance = poi1.distanceToUser();
                       }

If you check for !isNaN you make sure the calcualtion worked fine and you get a valid number. I had trouble with that on iOS where my pois started jumping up and down :)

kind regards,

Alexander

 

 
Login or Signup to post a comment