Community

Topic: Geo Augmented Markers

Marker Distance (SOLVED)

Nun Dabold
Tuesday, October 17, 2017

Is there a way to calculate distance from the current location to each marker? I would like to display that distance on the camera view and hide markers that are too far away, is that possible? Thanks.

user profile image
Support Team  (expert)
Wednesday, October 18, 2017

Hi,
You can have your current position in the onGeoLocationChanged method.
To calculate the difference between your position and the number of markers you want to show you can use:

iOS

let distanceInMeters = mCLLocation0.distance (from: mCLLocation1)
Android
float distanceInMeters = mLocation0.distanceTo (mLocation1);

Once you have defined a list of the markers you want to show based on the distance, you can call the showGeoElements method in iOS and the setGeoElements method on Android to update the markers.
You can also change the position update parameters
iOS
value (forKey: "geoManager") as! NSObject) .perform (Selector (("setGeolocationMinTime: andMinDistance:")), with: minTimeInSec, with: minDistanceInMeters)
Android
setLocationUpdateParameters (long minTime, float minDistance);

Best,

Nun Dabold
Thursday, October 19, 2017

Thanks for the assistance. I'm using Xamarin/IOS and your GeoTutorial. What is the correct syntax for the 'onGeoLocationChanged' event? I can't seem to get it to work.

user profile image
Support Team  (expert)
Friday, October 20, 2017

Hi,
if you want to implement the OnGeolocation method, you should
implement in PKTGeoMainController subclass the following method:

[Export ("onGeoLocationChanged:")]

public void GeoLocationChanged(NSObject location) {
}

Nun Dabold
Friday, October 20, 2017

That works, thank you very much.

Sign in to add a comment