Max url length with Google Maps static image
Asked Answered
E

5

6

I need to create a static image of google map with several markers, and each marker has a custom icon.

In the Api DOC there is the note: Static Map URLs are restricted to 2048 characters in size. In practice, you will probably not have need for URLs longer than this, unless you produce complicated maps with a high number of markers and paths.

The url is very long.... There is the position for each marker and the URL for the custom icon for each one. I've already tried with POST request ma it is not supported.

There is another way to create a static map image without max length limitation?

A possible way might be this, but i don't know if is it possible: I've create my custom map using the function in GMaps, and i have added all the markers i need. There is a way to access in static way to this particular map? so in the url i have to give only the center of the map and other parameters (zoom, ...), but all the markers are already positioned.

Or... another idea... Can i submit the URL of a KML with all markers positioned instead each single marker position+icon url?

Ell answered 25/10, 2011 at 22:19 Comment(2)
Do you have a solution for this? I have the same problem.Infantile
any solution? Still same problemArly
A
3

FYI, Google recently updated the limit to 8192.

Archibaldo answered 9/9, 2016 at 10:3 Comment(0)
I
2

Have you tried using a URL shortener for the icon urls? I believe the static map API will respect services that make URLs shorter... might save you a few characters.

Indamine answered 19/1, 2012 at 0:47 Comment(1)
Pretty sure this won't work. Based on what I imagine is happening at the http level (a redirect), Google wouldn't even see the shorter URL. Unless you have a service in mind that doesn't simply redirect to the longer URL?Protamine
R
0

You might wanna check out toopola´s API to help working with Google Static Maps, I am about to make my own attempt.

Rasberry answered 27/10, 2011 at 12:16 Comment(1)
This PHP Api use the normale url to get the map image (in the url there are the refer to all markers, so the max length problema is not solved). But i have another idea. Starting from this API i can mod the script to download the image of the map only, and converting the marker coordinates to image coordinates i can "watermark" the markers on the simple image.Ell
K
0

Another idea

  1. find map area that contains all the markers
  2. divide the map area into rectangular pieces (4 pieces for example)
  3. create image url for each part, but include in url only markers and icons visible on map
  4. show images

Мethod of division depends on the markers position.

Koressa answered 24/1, 2012 at 15:20 Comment(0)
C
0

Yes, you can definitely do this with the Javascript API.

I have built a few applications using that API. It can be a little tricky to get your head around, but it is pretty good. For what you want to do, it would not be too difficult. If the user has to be able to interact with the map and add pins and such, it starts to get a little more complicated because you have to capture clicks and such.

Does the map its self need to be available as a URL, or does it just need to be embedded on some page and that URL can be used?

The Javascript API will work best if you can embed the map into an existing webpage.

Christiniachristis answered 24/1, 2012 at 16:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.