Addmarker3 bitmapsize and Google Maps

bluedude

Well-Known Member
Licensed User
Longtime User
Hi,

I'm having troubles with displaying bitmaps as my placemarkers. My icons are 40x40 but on the map only a small part is shown of each .png.

Any suggestions?
 

Bobi

Member
Licensed User
Longtime User
Hi @warwound
I tried, using GoogleMapsExtras to create Markers (custom)

B4X:
Dim BitmapDescriptor1 As BitmapDescriptor
    Dim BitmapDescriptorFactory1 As BitmapDescriptorFactory
    BitmapDescriptor1=BitmapDescriptorFactory1.FromAsset("location1.png")
    Dim MarkerOptions1 As MarkerOptions
    MarkerOptions1.Initialize
    MarkerOptions1.Icon(BitmapDescriptor1)

    Dim Marker3 As Marker
    Marker3.Initialize("Jiblea", "...pe pe Valea Oltului", 45.29182, 24.370054, MarkerOptions1)

    Dim Markers As List
    Markers.Initialize2(Array As Object(Marker2, Marker3))
    MarkersFocusOverlay1.AddMarkers(Markers)

but I receive
error: package com.google.android.gms.maps.model does not exist

I added GoogleMaps library but I receive other error
Unknown member: initialize
. True, error appear at Marker3.Initialize

Hope you have a suggestion for my problem,
Thanks for your effort.

P.S. ref. art. https://www.b4x.com/android/forum/threads/google-maps-android-v2-tutorial.24415/page-7
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
There are 2 ways to create a Marker.

You can use one of the GoogleMaps library's 3 Add methods:
https://www.b4x.com/android/help/googlemaps.html#googlemap

Or you can use GoogleMapsExtras AddMarker(GoogleMap1 As GoogleMap, MarkerOptions1 As MarkerOptions) method.
This is the method you want to use.

Modify your code:

B4X:
Dim BitmapDescriptor1 As BitmapDescriptor
Dim BitmapDescriptorFactory1 As BitmapDescriptorFactory

BitmapDescriptor1=BitmapDescriptorFactory1.FromAsset("location1.png")

Dim MarkerOptions1 As MarkerOptions
MarkerOptions1.Initialize
MarkerOptions1.Icon(BitmapDescriptor1)
MarkerOptions1.Position2(45.29182, 24.370054)
MarkerOptions1.Snippet("...pe pe Valea Oltului")
MarkerOptions1.Title("Jiblea")

Dim Marker3 As Marker
Dim GoogleMapsExtras1 As GoogleMapsExtras
Marker3=GoogleMapsExtras1.AddMarker(GoogleMap1, MarkerOptions1)

Dim Markers As List
Markers.Initialize2(Array As Object(Marker2, Marker3))
MarkersFocusOverlay1.AddMarkers(Markers)

Martin.
 
Upvote 0

arnold steger

Member
Licensed User
Longtime User
Hi. What is the best solution to add 500 marker with description and a bitmap (Marker3).
I want to show or hidden marker on push button or when the zoom is too large.
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
That's a lot of Markers and might cause performance problems.
Have you tried adding 500 Markers to a map yet and testing the map for responsiveness?
That test ought be done on various devices - from low power devices to powerful devices.

Are these 500 Markers also relatively close to each other?
As the map is zoomed out will they turn into a mass of overlapping icons that are of no use to the user.
 
Upvote 0

arnold steger

Member
Licensed User
Longtime User
Have added all with
Dim Marker1 As Marker = GoogleMap1.AddMarker(....)
With my phones it works great.
Overlapping is my problem, i want to make better the view with my bitmap....
Or hidden the bitmap over max zoom.
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
You can listen for the MapFragment CameraChange (Position As CameraPosition) event.
In the sub that listens for that event look at the CameraPosition Zoom property.
Decide whether to show or hide Markers based on that zoom level.

There's no clustering feature available within b4a for GoogleMaps.

Another option is to use GoogleMapsExtras and it's Projection and VisibleRegion objects.
You can get a VisibleRegion that represents the current visible map area.
You can then iterate through your Markers to see if they are within this VisibleRegion - keep a count of how many Markers are currently visible.
If the number of Markers within the VisibleRegion is higher than a threshold then hide all Markers otherwise make them visible.
 
Upvote 0

arnold steger

Member
Licensed User
Longtime User
You have a code snippet for sub to read zoom and set a event when zoom >...
I have tested, the marker make always visible. With my bitmap isn`t a problem, when zoom >15 then make visibile the text of all my marker.
When the visibile area from the map moved is better to view always all my marker.
 
Upvote 0

achtrade

Active Member
Licensed User
Longtime User
Hi,

I'm having troubles with displaying bitmaps as my placemarkers. My icons are 40x40 but on the map only a small part is shown of each .png.

Any suggestions?

hi

I have this same issue, if the icon is 32x32 it's ok, but grater than that I got the issue.

How to fix it ?

thanks.
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Maybe it's a (built in) limitation of Google Maps?
Have you searched Google to see if it's a known limitation?
 
Upvote 0

achtrade

Active Member
Licensed User
Longtime User
Maybe it's a (built in) limitation of Google Maps?
Have you searched Google to see if it's a known limitation?

No, I haven't

But I don't think Google Maps has that limitation, there are a plenty of apps out there working with custom icon very well.
 
Upvote 0

StefanoAccorsi

Member
Licensed User
Longtime User
Hi I tried the example, but I receive an error:

B4X:
Dim BitmapDesctiptor1 As BitmapDescriptor
Dim BitmapDescriptorFactory1 As BitmapDescriptorFactory
BitmapDesctiptor1 = BitmapDescriptorFactory1.FromAsset("marker.png")
   
Dim MarkerOptions1 As MarkerOptions
MarkerOptions1.Initialize
MarkerOptions1.Icon(BitmapDesctiptor1)
MarkerOptions1.Position2(actualLocation.Latitude, actualLocation.Longitude)
MarkerOptions1.Title("Home")
MarkerOptions1.Snippet("Your home")
   
Dim Marker3 As Marker
Dim GoogleMapExtras1 As GoogleMapsExtras
If gmap.IsInitialized Then
    Marker3 = GoogleMapExtras1.AddMarker(gmap, MarkerOptions1)
End If

The error (a NullPointerException) is in the line Marker3 = GoogleMapExtras1.AddMarker(gmap, MarkerOptions1).

Now, gmap is initialized, MarkerOptions1 is initialized and set. What could be? Thank you.

BTW there's a place where I can find all the examples on GoogleMap and GoogleMapExtras?
 
Upvote 0
Top