Start a new topic

disance on marker

hello,

i'm trying to show the distance to poi on a marker but it returns "undefined" i tried the label : 

 

this.descriptionLabel = new AR.Label(World.onMarkerSelected.distanceToUserValue, 0.8, {
        zOrder: 1,
        translate: {
            y: 0.1
        },
        style: {
            textColor: '#ffa31a'
        }
    });

 and i called it in AR.GeoObject!


Hello Mohamed,

Please refer to this example in order to see how you can get and display the distance from a POI you have selected.

Thanks
Eva

 

yes Eva i did but i have a probleme in passing the variable of distance value to my marker a s label???

Hi Mohamed,

Did you try with our example to see if this is working for you? What kind of problem are you having?

Thanks
Eva

 

yes Eva i tried but no point !!!

my probleme is that i want to display the distance to a POI on the marker but i don't know how to create the label to do so !

Hi Mohamed,

You can create the label as suggested below
First you need to get the distance

 

var distanceToUserValue = (marker.distanceToUser > 999) ? ((marker.distanceToUser / 1000).toFixed(2) + " km") : (Math.round(marker.distanceToUser) + " m");
$("#poi-detail-distance").html(distanceToUserValue);

 

Then you need to add it to the details of the poi

 

//decide which data you want to saw within the label
var poiData = {
    "id": 1,
    "longitude": (lon + (Math.random() / 5 - 0.1)),
    "latitude": (lat + (Math.random() / 5 - 0.1)),
    "altitude": 100.0,
    "description": "This is the description of POI#1",
    "title": "POI#1"
//so here you can simply add the distance as well
};

 

Last step is to create the label. See here further instructions on how. Hope that helps.


Thanks

Eva

Login or Signup to post a comment