Platforms to show: All Mac Windows Linux Cross-Platform

/MacFrameworks/CoreLocation/Locate Address


Required plugins for this example: MBS MacFrameworks Plugin, MBS Main Plugin, MBS MacBase Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacFrameworks/CoreLocation/Locate Address

This example is the version from Tue, 15th Dec 2014.

Project "Locate Address.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control Addresse Inherits TextField
ControlInstance Addresse Inherits TextField
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() run End EventHandler
End Control
EventHandler Sub Open() geoCoder = new CLGeocoderMBS End EventHandler
Sub Run() List.DeleteAllRows dim g as new MyCLGeocodeCompletionHandlerMBS geoCoder.geocodeAddressString Addresse.Text, g // reference it by itself, so object stays in memory g.selfRef = g Exception n as NilObjectException MsgBox "Failed?" End Sub
Property geoCoder As CLGeocoderMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Class MyCLGeocodeCompletionHandlerMBS Inherits CLGeocodeCompletionHandlerMBS
EventHandler Sub Completed(geocoder as CLGeocoderMBS, placemarks() as CLPlacemarkMBS, error as NSErrorMBS, tag as variant) dim l as listbox = window1.List l.DeleteAllRows if error<>nil then l.AddRow "Error", error.LocalizedDescription end if l.AddRow "Count of placemarks", str(UBound(placemarks)+1) for each p as CLPlacemarkMBS in placemarks l.AddRow "name", p.name l.AddRow "locality", p.locality l.AddRow "subLocality", p.subLocality l.AddRow "thoroughfare", p.thoroughfare l.AddRow "subThoroughfare", p.subThoroughfare l.AddRow "administrativeArea", p.administrativeArea l.AddRow "subAdministrativeArea", p.subAdministrativeArea l.AddRow "postalCode", p.postalCode l.AddRow "country", p.country dim ad as Dictionary = p.addressDictionary for each key as Variant in ad.keys dim value as Variant = ad.Value(key) if value.IsArray then // convert array of variants with strings to string array for join dim v() as Variant = value dim s() as string for each k as Variant in v s.Append k.StringValue next value = Join(s, ", ") end if l.AddRow "Address "+key, value next l.AddRow "areasOfInterest", join(p.areasOfInterest, ", ") l.AddRow "ocean", p.ocean l.AddRow "inlandWater", p.inlandWater l.AddRow "ISOcountryCode", p.ISOcountryCode dim r as CLRegionMBS = p.region if r<>nil then l.AddRow "region latitude", str(r.latitude) l.AddRow "region longitude", str(r.longitude) l.AddRow "region radius", str(r.radius) end if dim cl as CLLocationMBS = p.location l.AddRow "Location Latitude", str(cl.Latitude) l.AddRow "Location Longitude", str(cl.Longitude) next Finally // clearnup selfRef = nil End EventHandler
Property selfRef As MyCLGeocodeCompletionHandlerMBS
End Class
End Project

See also:

The items on this page are in the following plugins: MBS MacFrameworks Plugin.


The biggest plugin in space...