Google Maps and a lot of path points (long polylin

2019-06-21 04:01发布

问题:

I try to integrate Google's static Maps service in my C# application. It should plot a custom route on a map. For example:

http://maps.google.com/maps/api/staticmap?size=512x512&path=color:0x0000ff|weight:5|40.737102,-73.990318|40.749825,-73.987963&sensor=false

This works well for a few path points (~ <75) but if the route is long enough the URI exceeds the 2048 characters limit and I get a 414 error message.

Is it possible to bypass this problem, perhaps with a POST?

Thank you!

回答1:

if you have a web serve you can save the points in a KML file hosted on your webserver then pass it along to google Maps http://code.google.com/apis/kml/documentation/whatiskml.html



回答2:

Nope you can't bypass that problem.What you can do is to maybe reduce the accuracy of the coords so that the url length gets reduced also.



回答3:

Google static image API does not support for viewing of KML file.



回答4:

Google recently changed the URL limit to 8192 characters in size.

You can see a feature request in public issue tracker that was marked as Fixed.

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