开发者

Google Maps Static Map - Custom icons limit

开发者 https://www.devze.com 2023-02-11 04:02 出处:网络
I am generating a static map from Google maps with up to 26 custom icons (in this example, 15), but for some reason it only loads the first 5 icons. Here is the URL:

I am generating a static map from Google maps with up to 26 custom icons (in this example, 15), but for some reason it only loads the first 5 icons. Here is the URL:

http://bit.ly/fGdtft

Does Google maps have a limit on the number of icons that can be loaded? There's nothing explicit in the documentation - all of the other imag开发者_Go百科es exist, in fact if I switch icon A with icon H, icon H will appear where icon A is supposed to be and where icon H is supposed to be: http://bit.ly/elk8kB

Has anyone else had success this this?


From the static api documentation :

 Static Maps service allows up to five unique custom icons per request. 
Note that each of these unique icons may be used multiple times within the static map.

Sorry :(


Here's how I got around this:

  1. You probably already know how, and depending on your source it's going to be different anyway, but collect up all your map data. Required bits are going to be: center point, zoom, map type, and output image size. I am going to assume sensor (if the application has access to GPS) is false. Also you are going to need all of your marker information which will include the icon you are going to use, and the geo coordinates of them.

  2. I POSTed this all to the CF page that is going to make all the magic happen.

  3. Map your first 5 points as normal. Get the results as a .png

  4. Map your next 5 points but add "style=feature:all|visibility:off" to the query string, get result as a .png. This will give you a png with a transparent background but will have all of your marker icons on it. It will be the same size as your initial map, and the markers will be placed correctly withing that rectangle.

  5. Watermark that image on top of your initial map. NOTE: this step is probably going to vary the most depending on your language of choice and what image manipulation features it offers.

  6. Repeat 4 and 5 until you have all of your markers.

  7. Write out you image with all of the markers now on it.

  8. Serve up a link to that file instead of using the normal google link.

I have a more detailed explanation here with some code example in ColdFusion.

0

精彩评论

暂无评论...
验证码 换一张
取 消