« Visualize electronic … | Home | MBS Xojo Plugins, ver… »

XDevMag: Find Yourself

How to determine the location of devices with MBS under Windows and Mac

article page

Let us point you to an article in the Xojo Developer Magazine in the 22.6 issue:

The article "Find Yourself" by Stefanie Juchmes explains how to determine the location of a device using MBS Xojo Plugins for both Windows and Mac platforms. On Windows, the process involves using the WindowsLocationManagerMBS class to request access to location data and start event handling. The article outlines how to create a class that inherits from this class, use the StartEvents method, and handle location updates through the LocationChanged event. It covers different status reports like whether location services are not supported, errors, or when the location service is running, allowing the application to react appropriately.

For Mac, the location retrieval process works similarly, using the CoreLocation framework and the CLLocationManagerMBS class. The process starts by checking if location services are available and enabled on the device. The class created in the Mac example inherits from CLLocationManagerMBS, and location updates are retrieved through the didUpdate event. Latitude, longitude, altitude, and timestamp can be fetched, and the article also touches on querying the data in a formatted text string, which can include speed, direction, and accuracy metrics. The process is straightforward, similar to the Windows implementation, with a focus on handling location updates and stopping them once the data is retrieved.

In addition to basic location retrieval, the article also explores advanced functionality on Mac, like using a GeoCoder to convert geographic coordinates into a street address. The author explains how to set up a GeoCoderHandler class to handle the completion event once the geocoding process is finished. This feature allows the user to obtain both address information for a set of coordinates and vice versa, making it versatile. By providing detailed examples and code snippets for both platforms, the article gives readers a comprehensive understanding of how to use MBS to get location data and even turn coordinates into readable addresses on Mac.

see CLLocationManagerMBS and WindowsLocationManagerMBS classes.

Please subscribe to the Xojo Developer Magazine and read this article and the ones coming later this year.

17 02 25 - 12:00