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
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)
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.
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}”)
Thank you for that excellent explanation. I will read more about anonymous objects. The code is working.
Please login first to submit.