Hi All again,
An existing working Google Maps App being updated to match new requirements.
In creating the markers an error is shown indicating the image for the marker can't be decoded. The image "markerghost.png" is the same as it has always been.
The error indicates .bmp files, I have tried several .bmp files but the same error is produced.
The Sub producing the error is below:
The part log file is below:
The ZIP is uploaded, note the Key is a dummy and would need to be replaced with a valid Map Key.
Any help greatly appreciated. It's probably obvious but I can't see why the changes in setting up the map would cause issues with this code.
Regards Roger
An existing working Google Maps App being updated to match new requirements.
In creating the markers an error is shown indicating the image for the marker can't be decoded. The image "markerghost.png" is the same as it has always been.
The error indicates .bmp files, I have tried several .bmp files but the same error is produced.
The Sub producing the error is below:
B4X:
Sub mFragment_Ready
gmap = mFragment.GetMap
' Sleep(100) same result as "rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)"
' 'Added as part of upgrade 10 Aug 19 Does not work.
' Log("Point1")
' rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
' Log("Point2") 'This point is logged
' Wait For Activity_PermissionResult (Permission As String, Result As Boolean) 'Bypasses the rest of the Sub
' Log("Point3") 'This point is not logged
' gmap.MyLocationEnabled = Result
' Log("result = "&Result)
'******* The following code in the Sub has not changed from the original working App ********
If gmap.IsInitialized = False Then
ToastMessageShow("Error initializing map.", True)
Log("BTSMarkerError")
Else
'Create BTSMarker Options including ICON
Private BTSOptions As MarkerOptions
Private BitmapDescriptor1 As BitmapDescriptor
Private BitmapDescriptorFactory1 As BitmapDescriptorFactory
BTSOptions.Initialize
BTSOptions.Draggable(True)
BTSOptions.Position2(BTSLat, BTSLng).Snippet("").Title("")
BTSOptions.Anchor(0.5, 0.5)
BitmapDescriptor1=BitmapDescriptorFactory1.FromAsset("markerghost.png") 'Tried several .bmp files, the error below remained.
'BitmapDescriptor3=BitmapDescriptorFactory3.FromAsset("markerghost.bmp")
BTSOptions.Icon(BitmapDescriptor1)
'Create BTSmarker
BTSMarker=GoogleMapsExtras1.AddMarker(gmap, BTSOptions) 'Error com.google.maps.api.android.lib6.common.apiexception.a: Failed to decode image. The provided image must be a Bitmap.
'Create LANDMarker Options including ICON
Private LANDOptions As MarkerOptions
Private BitmapDescriptor2 As BitmapDescriptor
Private BitmapDescriptorFactory2 As BitmapDescriptorFactory
LANDOptions.Initialize
LANDOptions.Draggable(True)
LANDOptions.Position2(LANDLat, LANDLng).Snippet("").Title("")
LANDOptions.Anchor(0.5, 0.5)
BitmapDescriptor2=BitmapDescriptorFactory2.FromAsset("markerghost.png")
LANDOptions.Icon(BitmapDescriptor2)
'Create LANDMarker marker
LANDMarker = GoogleMapsExtras1.AddMarker(gmap, LANDOptions)
'Create BEndMarker Options including ICON
Private BEndOptions As MarkerOptions
Private BitmapDescriptor3 As BitmapDescriptor
Private BitmapDescriptorFactory3 As BitmapDescriptorFactory
BEndOptions.Initialize
BEndOptions.Draggable(True)
BEndOptions.Position2(BLat, BLng).Snippet("").Title("")
BEndOptions.Anchor(0.5, 0.5)
BitmapDescriptor3=BitmapDescriptorFactory3.FromAsset("markerghost.png")
BEndOptions.Icon(BitmapDescriptor3)
'Create BEndMarker marker
BEndMarker = GoogleMapsExtras1.AddMarker(gmap, LANDOptions)
Private AnyDragListener As OnMarkerDragListener
AnyDragListener.Initialize("AnyDragListener")
GoogleMapsExtras1.SetOnMarkerDragListener(gmap,AnyDragListener)
PathDistance
ABearingCalc
OffSet
Select Mode
Case 0
pnlABDispLatLng.SendToBack
BTSIV.BringToFront
LMIV.BringToFront
AEndIV.SendToBack
BEndIV.SendToBack
pnlDispLatLng.BringToFront
'Locate Markers
Private LL As LatLng
LL.Initialize(BTSLat, BTSLng) 'the new Position
BTSMarker.Position = LL
Private LL As LatLng
LL.Initialize(LANDLat, LANDLng) 'the new Position
LANDMarker.Position = LL
'Center Map. Zoom in/out to display IV's
cp.Initialize2(MapLat, MapLng, 18, 0, 0 )
gmap.MoveCamera(cp)
cp.Initialize2(MapLat, MapLng, MapZoom, 0, 0 )
gmap.MoveCamera(cp)
'Draw Lines
HorizonPointLatLng
DrawLandMarkLine
DrawAntBearingLine
Case 1
pnlDispLatLng.SendToBack
BTSIV.SendToBack
LMIV.BringToFront
AEndIV.BringToFront
BEndIV.BringToFront
pnlABDispLatLng.BringToFront
Private LL As LatLng
LL.Initialize(ALat, ALng) 'the new Position
BTSMarker.Position = LL
Private LL As LatLng
LL.Initialize(BLat, BLng) 'the new Position
BEndMarker.Position = LL
Private LL As LatLng
LL.Initialize(ABLandLat, ABLandLng) 'the new Position
LANDMarker.Position = LL
cp.Initialize2(ABMapLat, ABMapLng, 18, 0, 0 )
gmap.MoveCamera(cp)
cp.Initialize2(ABMapLat, ABMapLng, ABMapZoom, 0, 0 )
gmap.MoveCamera(cp)
DrawLandMarkLine
DrawAntBearingLine
End Select
Select Mode
Case 0
HorizonPointLatLng
DrawLandMarkLine
DrawAntBearingLine
cp.Initialize2(MapLat, MapLng, MapZoom, MapBearing, 0 )
gmap.MoveCamera(cp)
gmap.maptype = MapTypeInt 'MapTypeInt: 1=Road Map, 2=Satellite, 3=Terrain, 4=Satellite with Labels
gmap.MyLocationEnabled = True
gmap.GetUiSettings.MyLocationButtonEnabled = False
gmap.GetUiSettings.CompassEnabled = True
Case 1, 3
DrawLandMarkLine
DrawAntBearingLine
cp.Initialize2(ABMapLat, ABMapLng, ABMapZoom, ABMapBearing, 0 )
gmap.MoveCamera(cp)
gmap.maptype = ABMapTypeInt 'ABMapTypeInt: 1=Road Map, 2=Satellite, 3=Terrain, 4=Satellite with Labels
gmap.MyLocationEnabled = True
gmap.GetUiSettings.MyLocationButtonEnabled = False
gmap.GetUiSettings.CompassEnabled = True
End Select
End If
Timer2.Initialize("Timer2",2500) 'Gives GPS time to lock before activating SunDial calcs. [2500ms]
Timer2.Enabled = True
End Sub
The part log file is below:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 502 (Main)
com.google.maps.api.android.lib6.common.apiexception.a: Failed to decode image. The provided image must be a Bitmap.
at com.google.maps.api.android.lib6.impl.i.acom.google.android.gms.dynamite_mapsdynamite@18382048@18.3.82 (040400-260264002):8)
at com.google.maps.api.android.lib6.impl.r.acom.google.android.gms.dynamite_mapsdynamite@18382048@18.3.82 (040400-260264002):5)
at com.google.maps.api.android.lib6.impl.dh.<init>com.google.android.gms.dynamite_mapsdynamite@18382048@18.3.82 (040400-260264002):15)
at com.google.maps.api.android.lib6.impl.be.acom.google.android.gms.dynamite_mapsdynamite@18382048@18.3.82 (040400-260264002):389)
The ZIP is uploaded, note the Key is a dummy and would need to be replaced with a valid Map Key.
Any help greatly appreciated. It's probably obvious but I can't see why the changes in setting up the map would cause issues with this code.
Regards Roger