Community
Topic: Geo Augmented Markers
Marker Distance (SOLVED)
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.
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,
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.
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) {
}
That works, thank you very much.