Google Maps Markers and Colors

DTsEMT

Member
Licensed User
Longtime User
I would like to add different points on a google map as Markers. Each Marker can be a different color.

Using the standard GoogleMaps library, this worked with the AddMarker2 class where I could specify a HUE_<name>. However, this library didn't let me remove individual markers (so I could add them back in as the location changed).

Using GoogleMapExtras library I can remove them, (with .REMOVE) but there is no color specification that I've been able to find.

Using the Extras library again, I can switch over to using circles, which can be any color (not just those available with Addmarker2 and HUE_xxx), but I lose the ability to put text or snippets!

Right now, the only alternative seems to be creating multiple icons of different colors, and the Extras library to add them in with

Dim Markeroptions1 as Markeroptions
Markeroptions1.Icon=xxx

But that of course limits the user to whatever colors I provide, rather than a colorpicker dialog.

Does anyone know how I can use the Extras library, keep Title and Snippets, but change the colors of the map markers?

Thanks!
 

warwound

Expert
Licensed User
Longtime User
Look at the Google Maps Extras BitmapDescriptor and BitmapDescriptorFactory objects.
The BitmapDescriptorFactory has a method:

DefaultMarker2 (Hue As Float) As BitmapDescriptor
Creates a BitmapDescriptor that refers to a colorization of the default marker image.

You can pass the BitmapDescriptor to the MarkerOptions Icon method.

Martin.
 
Upvote 0

DTsEMT

Member
Licensed User
Longtime User
Thanks, Warwound! That did it! I can now assign a colored map marker:
TmpStudent.LastFixTime=DateTime.Now 'set the info
TmpStudent.Latitude=PartsString(0)
TmpStudent.Longitude=PartsString(1)
TmpStudent.Altitude=PartsString(2)
TmpStudent.Speed=PartsString(3)
TmpStudent.MapMarker.Remove
Log("Old Marker Removed")
Dim MarkerOptions1 As MarkerOptions
MarkerOptions1.Initialize
MarkerOptions1.Position2(TmpStudent.Latitude, TmpStudent.Longitude)
MarkerOptions1.Snippet(TmpStudent.MemberName).Title(TmpStudent.MemberInitials)
Dim BitmapDescriptor1 As BitmapDescriptor
Dim BitmapDescriptorFactory1 As BitmapDescriptorFactory
BitmapDescriptor1=BitmapDescriptorFactory1.DefaultMarker2(BitmapDescriptorFactory1.Hue_Azure)
MarkerOptions1.Icon(BitmapDescriptor1)
MarkerOptions1.visible(True)
TmpStudent.MapMarker=GoogleMapExtras1.addmarker(gmap,MarkerOptions1)

Thanks again!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…