Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacFrameworks/CoreLocation/Locate Address Web
Function:
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 Tue, 15th Dec 2014.
Project "Locate Address Web.rbp"
Class App Inherits WebApplication
EventHandler Sub Open() 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 Action() run End EventHandler
End Control
EventHandler Sub Open() geoCoder = new CLGeocoderMBS End EventHandler
Sub Run() List.DeleteAllRows 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 MsgBox "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.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 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
End Project

See also:

Feedback, Comments & Corrections

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




Links
MBS Xojo Plugins