'Avvio applicazione inizializzazione mappa prima di tutto il resto
Sub Initialize_Map
Dim CameraPosition As CameraPosition
fldInitializeMap.Visible = True
'Visualizza se il traffico è abilitato
Functions.Set_ObjectColor(Activity,chkTrafficEnabled,Colors.White,Colors.White)
chkTrafficEnabled.Checked = AppSettings.TrafficEnabled
Try
Wait For Map_Ready
GoogleMap = Map.GetMap
If GoogleMap.IsInitialized = True Then
[B]RP.CheckAndRequest(RP.PERMISSION_ACCESS_FINE_LOCATION)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)[/B]
If Result = True Then
GoogleMap.MyLocationEnabled = True
GoogleMap.MapType = AppSettings.MapType
GoogleMap.TrafficEnabled = AppSettings.TrafficEnabled
'Attendo la localizzazione
Do While GoogleMap.MyLocation.IsInitialized = False
Sleep(200)
Loop
'Visualizzo la posizione corrente
If GoogleMap.MyLocation.IsInitialized = True Then
AppDeclares.CurrentLatitude = GoogleMap.MyLocation.Latitude
AppDeclares.CurrentLongitude = GoogleMap.MyLocation.Longitude
fldCurrentCoordinates.Text = "Lat.: " & NumberFormat2(AppDeclares.CurrentLatitude,1,4,4,False) & _
" Lon.: " & NumberFormat2(AppDeclares.CurrentLongitude,1,4,4,False)
CameraPosition.Initialize(AppDeclares.CurrentLatitude,AppDeclares.CurrentLongitude,AppSettings.MapZoom)
GoogleMap.MoveCamera(CameraPosition)
End If
Else
pnlGoogleMaps.Visible = False
ToastMessageShow("Permesso utilizzo GoogleMaps negato",False)
End If
Else
pnlGoogleMaps.Visible = False
ToastMessageShow("Errore caricamento GoogleMaps",False)
End If
Catch
pnlGoogleMaps.Visible = False
ToastMessageShow("Errore inizializzazione GoogleMaps",False)
End Try
fldInitializeMap.Visible = False
End Sub