Just starting out? Need help? Post your questions and find answers here.
Dirk Geppert
 
Posts: 99
Joined: Fri Sep 22, 2017 7:02 am

StartGeoLocation() does not work on Safari

by Dirk Geppert Wed Nov 21, 2018 5:27 pm

Does not work on Safari/iPhone: the Browser dont ask me, to allow the geolocation..

You can try it here:
http://h2717740.stratoserver.net/app/geo/index1.html

or with an Map:
http://h2717740.stratoserver.net/app/geo/index.html

Code: Select all
Enumeration
  #Window
  #Button
  #Link
EndEnumeration


Procedure TimerEvent()
 
  Static x.d, y.d
  Protected flags
 
  If x <> GeolocationLatitude()
    x = GeolocationLatitude()
    flags = #True
  EndIf
 
  If y <> GeolocationLongitude()
    y = GeolocationLongitude()
    flags = #True
  EndIf
 
  If flags = #True
    Debug "GeolocationTime: " + GeolocationTime()
    Debug "GeolocationLatitude: " + GeolocationLatitude()
    Debug "GeolocationLongitude: " + GeolocationLongitude()
    Debug "----"
  EndIf
EndProcedure

Procedure Start_Locating()
  Static flags = #False
 
  If flags = #False
    flags = #True
    Debug "StartGeolocation()"
    StartGeolocation()
    SetGadgetText(#Button, "Stop")
   
    AddWindowTimer(0, 0, 1000)
    BindEvent(#PB_Event_Timer, @TimerEvent(), 0, 0)
   
  Else
    flags = #False
    StopGeolocation()
    Debug "StoppGeolocation()"
    SetGadgetText(#Button, "Start again")
    RemoveWindowTimer(0, 0)
    UnbindEvent(#PB_Event_Timer, @TimerEvent())
  EndIf
EndProcedure

Procedure Main()
 
  OpenWindow(#Window, #PB_Ignore, #PB_Ignore, 500, 500, "GeoLocation", #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
 
  ButtonGadget (#Button, 0, WindowHeight(#Window) - 20, WindowWidth(#Window)/2, 20, "Start Locating..")
  BindGadgetEvent(#Button, @Start_Locating(), #PB_EventType_LeftClick)
 
  TextGadget (#Link, WindowWidth(#Window)/2, WindowHeight(#Window) - 20, WindowWidth(#Window)/2, 20, "")
  SetGadgetText (#Link,  ~"<a href = \"#\" button onclick=\"f_start_locating()\">Try it from here It</a>")

 
EndProcedure

Main()
Fred
Site Admin
 
Posts: 1130
Joined: Mon Feb 24, 2014 10:51 am

Re: 2.21B StartGeoLocation() does not work on Safari

by Fred Sun Jan 27, 2019 1:42 pm

Safari only allows geolocation if the site is secured (https://). I will add this to the doc.
Return to Coding Questions

Who is online

Users browsing this forum: No registered users and 5 guests