Community
Topic: Xamarin component
onGeoLocationChanged method (SOLVED)
I'm using IOS/Xamarin and I'm trying to use the onGeoLocationChanged method to check distance from current location to my Points of Interest, but I don't know how to use the GeoLocationChanged event. I tried it as an override but that wasn't recognized. Could you please either point to an IOS example or show me the basic code to setup a listener to this method? Thanks very much.
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) {
}
The onGeoLocationChanged method is a method of the PKTIArGeoListener interface, that is implemented (with empty implementation) by PKTGeoMainController class:
public interface PKTIArGeoListener {
[Export ("onGeoElement:Click:")]
void GeoElementClicked(NSObject geoElement, UIView view);
[Export ("onGeoLocationChanged:")]
void GeoLocationChanged(NSObject location);
[Export ("onMapOrCameraClicked")]
void OnMapOrCameraClicked();
}
That works, thank you very much.
I have the basics working with 'GeoLocationChanged', calculating distance between current location and each marker but the 'GeoLocationChanged' only seems to fire once and the location is not changing as I walk around.
Hi,
GeoLocationChanged callback is called when user location exceeds a minimum distance (in meters) and a minimum refresh time (in sec) from last user location.
By default, this value are 100 meters and 1 sec.
If you would like to change this parameters, you should set them in PKTGeoMainController subclass as follow:
ValueForKey(new NSString("_geoManager")).SetValueForKey(new NSNumber(), new NSString("_minDistanceGeolocationChange"));
ValueForKey(new NSString("_geoManager")).SetValueForKey(new NSNumber(), new NSString("_minTimeGeolocationChange"));
We suggest to set this value at lowest value (1 meter for _minDistanceGeolocationChange and 0 sec in _minTimeGeolocationChange) and makes some tuning,
depending on your app requirements.
Regards