Platforms to show: All Mac Windows Linux Cross-Platform

/MacFrameworks/CoreLocation/Locate Address Web


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 Web

This example is the version from Mon, 6th Nov 2022.

Project "Locate Address Web.xojo_binary_project"
Class App Inherits WebApplication
EventHandler Sub Opening(args() as String) t = new CoreLocationEventsTimer End EventHandler
Property t As CoreLocationEventsTimer
End Class
Class Session Inherits WebSession
Const ErrorDialogCancel = "Do Not Send"
Const ErrorDialogMessage = "This application has encountered an error and cannot continue."
Const ErrorDialogQuestion = "Please describe what you were doing right before the error occurred:"
Const ErrorDialogSubmit = "Send"
Const ErrorThankYou = "Thank You"
Const ErrorThankYouMessage = "Your feedback helps us make improvements."
Const NoJavascriptInstructions = "To turn Javascript on, please refer to your browser settings window."
Const NoJavascriptMessage = "Javascript must be enabled to access this page."
End Class
Class WebPage1 Inherits WebPage
Control List Inherits WebListBox
ControlInstance List Inherits WebListBox
End Control
Control Addresse Inherits WebTextField
ControlInstance Addresse Inherits WebTextField
End Control
Control Button1 Inherits WebButton
ControlInstance Button1 Inherits WebButton
EventHandler Sub Pressed() run End EventHandler
End Control
EventHandler Sub Opening() geoCoder = new CLGeocoderMBS End EventHandler
Sub Run() List.RemoveAllRows dim g as new MyCLGeocodeCompletionHandlerMBS g.list = List g.targetSession = session geoCoder.geocodeAddressString Addresse.Text, g // reference it by itself, so object stays in memory g.selfRef = g Exception n as NilObjectException MessageBox "Failed?" End Sub
Property geoCoder As CLGeocoderMBS
End Class
Class MyCLGeocodeCompletionHandlerMBS Inherits CLGeocodeCompletionHandlerMBS
EventHandler Sub Completed(geocoder as CLGeocoderMBS, placemarks() as CLPlacemarkMBS, error as NSErrorMBS, tag as variant) dim w as new WebSessionContext(targetSession) dim l as WebListBox = List l.RemoveAllRows 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 list = nil targetSession = nil End EventHandler
Property list As WebListBox
Property selfRef As MyCLGeocodeCompletionHandlerMBS
Property targetSession As WebSession
End Class
Class CoreLocationEventsTimer Inherits Timer
EventHandler Sub Action() // for web app, check every few Milliseconds if something happend CLLocationManagerMBS.CheckEvents End EventHandler
Sub Constructor() mode = 2 Period = 500 End Sub
End Class
Sign
End Sign
End Project

See also:

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


The biggest plugin in space...