2

I'm generating a google static map URL. Because of the map style, it's coming out very long. The google docs say the maximum URL length is 2048. It seems strange to me that google would impose this limit when styling is so verbose and must be included in the URL. It would be nice if they let you instead pass the URL to a style sheet the way they let you pass a URL to a marker image.

Anyway, my URL is 2295 characters, but google is returning the map to me without any complaints. I thought maybe google was counting characters after URL Decoding the URL, but if I add additional markers to extend my decoded URL length past 2048 characters, it still works. My worry is that they may fix this in the future and stop accepting my URLs. Does anyone know if there's a good reason why the length is not being limited?

Example (Requires a valid API key)

https://maps.googleapis.com/maps/api/staticmap?center=30.911406,-90.805644&zoom=13&size=640x640&maptype=roadmap&style=feature%3aadministrative%7celement%3alabels.text.fill%7ccolor%3a0x044444&style=feature%3aadministrative.neighborhood%7cvisibility%3aoff&style=feature%3alandscape%7ccolor%3a0x02f2f2&style=feature%3alandscape%7celement%3ageometry.fill%7ccolor%3a0x0fffff&style=feature%3apoi%7cvisibility%3aoff&style=feature%3aroad%7csaturation%3a-100%7clightness%3a45&style=feature%3aroad.highway%7cvisibility%3asimplified&style=feature%3aroad.highway%7celement%3ageometry.fill%7csaturation%3a100%7ccolor%3a0x05c1e8%7cvisibility%3aon%7cweight%3a2.19%7clightness%3a0%7cgamma%3a1&style=feature%3aroad.highway%7celement%3ageometry.stroke%7cweight%3a1.00%7cvisibility%3aon%7ccolor%3a0x05c1e8%7clightness%3a-12&style=feature%3aroad.arterial%7celement%3ageometry.fill%7cvisibility%3aon%7ccolor%3a0x05c1e8%7cweight%3a1.79%7cgamma%3a1%7clightness%3a0%7csaturation%3a100&style=feature%3aroad.arterial%7celement%3ageometry.stroke%7cvisibility%3aoff&style=feature%3aroad.arterial%7celement%3alabels.text.fill%7ccolor%3a0x0287d4%7cvisibility%3aon%7cweight%3a10.00%7csaturation%3a81%7clightness%3a-16%7cgamma%3a1&style=feature%3aroad.arterial%7celement%3alabels.icon%7cvisibility%3aoff%7csaturation%3a48&style=feature%3aroad.local%7celement%3ageometry.fill%7ccolor%3a0x03e5f6%7cvisibility%3aon%7cweight%3a1.51%7csaturation%3a100%7clightness%3a16&style=feature%3aroad.local%7celement%3ageometry.stroke%7cweight%3a1.35%7cvisibility%3aoff&style=feature%3aroad.local%7celement%3alabels.text.fill%7ccolor%3a0x01d7eb%7cweight%3a3.03%7clightness%3a-21&style=feature%3aroad.local%7celement%3alabels.text.stroke%7cweight%3a2.33&style=feature%3atransit%7cvisibility%3aoff&style=feature%3awater%7ccolor%3a0x06bcec%7cvisibility%3aon&style=feature%3awater%7celement%3ageometry.fill%7cvisibility%3aon%7ccolor%3a0x0ae1e1%7clightness%3a7%7csaturation%3a-5&style=feature%3awater%7celement%3ageometry.stroke%7cvisibility%3aoff&style=feature%3awater%7celement%3alabels.text%7ccolor%3a0x066666&style=feature%3awater%7celement%3alabels.text.stroke%7cvisibility%3aoff&markers=icon:http%3a%2f%2fwww.mydomain.com%2fClientResources%2fassets%2fimages%2fmap-marker.png%7C30.911406,-90.805644&key=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

xr280xr
  • 12,621
  • 7
  • 81
  • 125

2 Answers2

4

We have updated the Developer documentation to reflect the new 8192 character limit on URL length. Thanks!

Brett
  • 2,399
  • 1
  • 17
  • 23
0

The URL length is a browser restriction, not a Google restriction.

Related question: What is the maximum length of a URL in different browsers?

Community
  • 1
  • 1
geocodezip
  • 158,664
  • 13
  • 220
  • 245
  • How can I be sure? [Their doc](https://developers.google.com/maps/documentation/static-maps/intro#url-size-restriction) reads, "Google Static Maps API URLs are restricted to 2048 characters in size." That is not worded as browser restriction. It's worded specifically referencing Google Static Maps. They wouldn't need to present a general browser compatibility guideline as a hard rule in their documentation like this either since which browser(s) to support is the decision of the developer. You may be right but the wording makes me think they've at least reserved the right to reject longer URLs – xr280xr Jul 29 '16 at 21:29
  • 1
    You could open [an issue in the issue tracker](https://code.google.com/p/gmaps-api-issues/) if you believe it is a bug or the documentation is not clear. – geocodezip Jul 29 '16 at 22:51