谷歌地图静态api url长度超过2048 char是否有任何解决方案? 目标是保存为图像

so far I used google map api in javascript as well as in php, I had no problem in creating thousands of markers using these api, but my final aim is to save them as image, so finally I came to know that I have to use static make api, in order to save it as image., so tried static map api with few markers, I could able to save, but when tried with 1000's of markers I did not succeed, through many search on this forum I came to know that url limit is exceeding 2048 char, yes that is true.

So is there any alternate way to save map with thousands of markers ? in case of googlemap api in javascript/php I can see all markers, but nowhere I found solution for how to save them locally ?

whether anyone here found solution to save ? something like screen shot or you can say writing a content of map division to png / jpeg/ gif file ?

Please someone help me.

Thanks.

OK first let's talk TOS. As a couple commenters have pointed out you're not allowed to save maps offline. The specific section 10.1.1(h) which forbids you from using static maps outside of a web based app except in a couple specific situations. Print is not one of those - just in case. Section 10.1.3 also says "No Pre-Fetching, Caching, or Storage of Content" which means you can't take a map and just store it somewhere for later use. Caching for performance reasons is fine.

Now assuming you're OK with both of those things, the static Maps Image API is useful but not really useful for your specific use case. While you can encode polylines using the special encoding function, you can't put on a bunch of markers like you're intending. One thing you could do is to download the static maps API image without markers. You know the physical dimensions of the image and the bounding box in lat/long. It's trivial to convert that to degrees/pixel. You could use an the PHP image functions to convert the lat/lng to x/y pixels and manually place the markers on the image.

As long as you use the subsequent image output back in your webpage and only cache the image for a specific short period of time (a.k.a performance reasons) you should have no problems with the Maps TOS.

Please note that now (September 2016) the URL limit has been changed to 8192 characters in size.

https://developers.google.com/maps/documentation/static-maps/intro#url-size-restriction

Here is the corresponding feature request.