Anyway to overcome the 5 custom icon urls per request?

点点圈 提交于 2019-12-10 19:38:03

问题


From the Google Image 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

I have more than 5 custom icons per request, maybe up to 40.

Is there a way to overcome this? Is it possible to use sprites in static maps to overcome this?


回答1:


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.



来源:https://stackoverflow.com/questions/9893945/anyway-to-overcome-the-5-custom-icon-urls-per-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!