I've seen lots of other questions similar to this (here, here and here), but they all have accepted answers that don't solve my problem. The best solution I have found to the problem is the StyledMarker library, which does let you define custom colours for markers, but I can't get it to use the default marker (the one you get when you do a google maps search - with a dot in the middle), it just seems to provide markers with a letter in, or with a special icon.
相关问题
- How do you change the color of the dotted line on
- Add HTML class/ID to Google Maps Marker (API V3)
- Google maps how to force marker on the nearest roa
- Google Maps API v3 Hiding and showing a circle bou
- google maps adding overlay layer above UI and mark
相关文章
- Avoiding “Sorry, we have no imagery here” with Goo
- Cursor disappears in Google Maps application
- How to draw a proper polylines on google maps [clo
- Draw a rectangle arround a polygon when given in c
- Disable 'use strict' in Google Maps Drawin
- Unable to rotate kml layer
- Opening only a infobox at a time when multiple mar
- How to change strokeColor between points when usin
change it to chart.googleapis.com for the path, otherwise SSL won't work
Well the closest thing I've been able to get with the StyledMarker is this.
The bullet in the middle isn't quite a big as the default one though. The StyledMarker class simply builds this url and asks the google api to create the marker.
From the class use example use "%E2%80%A2" as your text, as in:
You will need to modifiy StyledMarker.js to comment out the lines:
as this will trim the text string to 2 characters.
Alternatively you could create custom marker images based on the default one with the colors you desire and override the default marker with code such as this:
I've extended vokimon's answer a bit, making it a bit more convenient for changing other properties as well.
Usage:
Or when defining a new marker:
Combine a symbol-based marker whose path draws the outline, with a '●' character for the center. You can substitute the dot with other text ('A', 'B', etc.) as desired.
This function returns options for a marker with the a given text (if any), text color, and fill color. It uses the text color for the outline.
Hi you can use icon as SVG and set colors. See this code
Here is a nice solution using the Gooogle Maps API itself. No external service, no extra library. And it enables custom shapes and multiple colors and styles. The solution uses vectorial markers, which googlemaps api calls Symbols.
Besides the few and limited predefined symbols, you can craft any shape of any color by specifying an SVG path string (Spec).
To use it, instead of setting the 'icon' marker option to the image url, you set it to a dictionary containing the symbol options. As example, I managed to craft one symbol that is quite similar to the standard marker:
I you are careful to keep the shape key point at 0,0 you avoid having to define marker icon centering parameters. Another path example, the same marker without the dot:
And here you have a very simple and ugly coloured flag:
You can also create the paths using a visual tool like Inkscape (GNU-GPL, multiplatform). Some useful hints: