Convert Google map with huge amount of data to a static using Google Static Maps

六月ゝ 毕业季﹏ 提交于 2019-12-13 07:23:05

问题


I need to convert a map built with Google Maps to a static map. The problem is that map has an amount of data (mainly circles), and its representation has to be doing a path description of its circunference, and I need some kind of accurate, a pure circle has to be displayed in the static mode, so each circle description is about 500 chars (encoded).

The Google Static Maps url limit is 8192 and its not enough for rendering those shapes. There is another way for doing it? I also tried to use html2canvas, but it is forbidden by Google.


回答1:


Google actually recently extended the URL limit to 8192, but if you need more than that you probably need to resort to taking a screenshot of a Google Maps JavaScript API map, as suggested by xomena.




回答2:


A tool like PhantomJS [1] can help you write a script to automatically take a screenshot of a webpage (which you've drawn using the Google Maps JavaScript API).

[1] https://github.com/ariya/phantomjs/wiki/Screen-Capture

I have a small example that uses PhantomJS to take a screenshot of the page.

Here's the JavaScript Map with some information: http://jsbin.com/pevizusana/2/edit

Here's the PhantomJS code that will take a screenshot on this site: http://pastebin.com/gEXhG1dP

And here's the result: http://i.imgur.com/Mj951aP.jpg

I hope you find this information helpful.



来源:https://stackoverflow.com/questions/39325715/convert-google-map-with-huge-amount-of-data-to-a-static-using-google-static-maps

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