Google Map marker w/ custom icon

Answered
0
0

Hi, I’m trying to use the GoogleMap.AddMarker method to use a custom marker icon.  I’m having trouble figuring out the syntax for the 3rd parameter, which is the MarkerOptions object specification…  Can you help me out?

Me.mobjGoogleMap.AddMarker(“test”, Me.sngLastLat, Me.sngLastLon, “icon: http://www.domain.com/path/to/marker/icon.png”)

https://developers.google.com/maps/documentation/javascript/3.exp/reference#MarkerOptions

  • You must to post comments
Best Answer
0
0

Sorry, my fault. I thought it was javascript code.

Wisej automatically converts any object, including anonymous objects, to JSON.  So the options object can be a an instance of a class that you define in your code, or an anonymous type. All the member names are converted using camel casing.

The anonymous definition in VB looks like this.

Me.mobjGoogleMap.AddMarker("test", Me.sngLastLat, Me.sngLastLon, New With {.icon = "http://www.domain.com/path/to/marker/icon.png"})

.icon can also be .Icon.

Or you can define an options class and to this:

Dim options as New MarkerOptions()
options.Icon = "http://www.domain.com/path/to/marker/icon.png"
Me.mobjGoogleMap.AddMarker("test", Me.sngLastLat, Me.sngLastLon, options)

 

  • You must to post comments
0
0

Thank you for that excellent explanation. I will read more about anonymous objects. The code is working.

  • You must to post comments
0
0

That doesn’t compile in VB. I tried putting the braces inside the quotes, and that didn’t work either…

Me.mobjGoogleMap.AddMarker(“test”, Me.sngLastLat, Me.sngLastLon, “{icon: http://www.domain.com/path/to/marker/icon.png}”)

  • You must to post comments
0
0

Try this: { insted of ”

Me.mobjGoogleMap.AddMarker(“test”, Me.sngLastLat, Me.sngLastLon, {icon: “http://www.domain.com/path/to/marker/icon.png”})

Options usually are javascript maps.

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.