I'm fairly new to google maps and this problem has me stuck for days now.
I basically have a set of coordinate points that I convert into a GMSPath object. This path object is then used to draw and render a GMSPolyline on my GMSMapView. This works absolutely fine. Now I need to get a shareable link for this polyline so that it can be drawn on google maps in a web browser. I've tried sharing following link and browser renders it fine:
http://maps.googleapis.com/maps/api/staticmap?center=33.402285,-111.942715&zoom=20&size=600x600&maptype=satellite&sensor=false&path=color:red|weight:1|fillcolor:white|33.4022475,-111.9426775|33.4022475,-111.9427525|33.4023225,-111.9427525|33.4023225,-111.9426775|33.4022475,-111.9426775
and this works perfectly for a few coordinate points. In my case however, I may get 500-1000 location coordinates.Which exceeds the maximum character limit of web browsers. Could anybody please point out where I should be looking instead? Any help would be highly appreciated.
Maybe you could have a look at what Google calls "encoded polylines". Basically it's the same thing as what you're doing, but with a specific encoding design to reduce a little bit the URL size. See here for how it works: https://developers.google.com/maps/documentation/staticmaps/#Paths. And a more detailed article: https://developers.google.com/maps/documentation/utilities/polylinealgorithm. Note that with this method you could also spare the center
and zoom
parameters in your URL.
But if you are still building URLs longer than 2.048 bytes using this method, I'm afraid you won't be able to get past the browser limit using the Google Maps Static API. 500 to 1.000 locations is likely too much for this purpose, even with encoded polylines... Good luck anyway!