Max url length with Google Maps static image - google-maps

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?

FYI, Google recently updated the limit to 8192.

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.

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

Another idea
find map area that contains all the markers
divide the map area into rectangular pieces (4 pieces for example)
create image url for each part, but include in url only markers and icons visible on map
show images
Мethod of division depends on the markers position.

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.

Related

How do you shift the centre of the map in an embedded Google map?

I have a Google Map that I have embedded on my web site. I have managed to size and position the iFrame so that it sits where I want it to sit on my web page. I am using the new Google Maps version.
However, I want to be able to shift the centre of the map to the right, because as it standsnow, the box that displays the map layers is covering some of the locations I have marked.
I am not at this point using any Javascript or jQuery. I have simply taken the iFrame link provided by Google's embed feature and placed it in my HTML. I see there are other questions about map centering, but I can't parse them for my situation because they assume some Javascript implementation. Also, I'm hoping that I do not have to take on a whole API or Javascript library to solve this. Further, it is unclear to me if the other questions relate to the new Google Maps version, which is what I'm using.
Is there a way I can alter the centre of the embedded Google Map?
Just add a "center" parameter to your iframe url. Like so - center="40.714728,-73.998672". You can get the required coordinates by searching in google maps and picking them from the address.
You could alternatively also use a query parameter but center is more accurate.
refer - https://developers.google.com/maps/documentation/static-maps/intro#location

Is there any limit to number of markers that can be placed on google static maps?

Is it possible to place (say 1000) markers (using set of LAT-LONG values) on Static Google map image?
Also, is there some sort of HTTP POST method to achive this or URL is the only way to go?
Basically, I was looking into Bing maps REST service - Imagery and I found that maximum 100 pushpins (markers) can be placed on to Bing map.
I would like to generate static map with unlimited markers/pushpins. Google or Bing does not matter.
Something like this: http://msdn.microsoft.com/en-us/library/ff701724.aspx#code-snippet-19
As far as I know there is no limit on how many markers you can add to a google-maps based map - however the performance of your map will decrease when you add a lot of them.
There is a nice article on developers.google.com (https://developers.google.com/maps/articles/toomanymarkers) that shows how to deal with lots of placemarks by either clustering them or rendering them on a separate layer.
The documentation for static maps states:
URL Size Restriction
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. Note, however, that certain characters may be URL-encoded by browsers
and/or services before sending them off to the Static Map service, resulting in increased
character usage. For more information, see Building a Valid URL.
I am pushing over 16000 markers with no problem at all, not even performance. I am using the javascript API, as long as you can put that into a variable, and push it to the canvas at a reasonable pase (1 per seccond is the speed i am pushing the markers ) there's no problem

URL to dynamic Google Map with path

I want to build a URL to a dynamic map (i.e., to the normal Google Maps interface where you can pan and zoom, rather than an image of a static map) that has a path drawn on it from lat-long coordinates.
Similar questions have been asked with answers that won't solve my problem:
How to obtain a dynamic map from a static map URL? : This guy wanted to add some markers on the map (lines between them would make a path like I want), and was told it was not possible with URL parameters.
How to obtain a dynamic map from a static map URL? : Yes, this guy asked the same question. He was told to change the URL just slightly, but if you follow the URL to the dynamic map, you can see it does not draw what is seen in the static map (e.g., many of the parameters are ignored and stripped).
For KML output, how can I add waypoints between source and destination addresses in a Google Maps URL? : I understand I can ask for driving directions with saddr, daddr, and +to:, but I just want a poly-line path, not driving directions.
I've seen many links to http://mapki.com/wiki/Google_Map_Parameters documenting the URL parameters, but that site has since disappeared, and no other documentation (even the official one) seems to come close to this guy's tedious work.
So is it just not possible? Are driving directions the best I can do?
Thank you for your consideration.
The best you can do you've already found here: http://www.seomoz.org/ugc/everything-you-never-wanted-to-know-about-google-maps-parameters
Create a KML which contains the desired features(markers, polylines,markers etc.)and pass the URL of the KML-file as q-parameter to google-maps.
The KML-file may be created on the fly, so you may pass details for the features to your script that creates the KML.

google maps: find out coordinates

i'm parsing some html data which has google maps embedded (displaying just one certain point) and i was wondering:
how can i find out the exact geographic coordinates of that point?
thx
I will look into this further but if you are able to see the Google Maps representation, you can type this into your browser and it will pinpoint the exact center location:
javascript:void(prompt('',gApplication.getMap().getCenter()));
Very useful if you want to get quick lat/long values. Is this the kind of info you need?
Parsing HTML files and want to find what point map is displaying?
This is likely not be possible (correct me if I am wrong). The map is a JavaScript object that only exists inside a browser - it is only text code in the html file. Map variables and data only exist inside the JavaScript engine running inside the browser, their dynamic variable state cannot be stored in a file ahead of time.
If the site is displaying a static map image then we have a different story. Just parse the URL to google static maps requesting the map image.
i found out that the actual coordinates were stored in the html :)
Have you tried the LatLng Marker lab in google map?

Can I change the marker in a Google Maps embedded map (iframe)?

I know I can do it with the Google Maps API, but do you know if there is a way to change the marker in an embedded Google Map?
I want to replace the default "A" button for a "B" button or the marker with just a dot in the middle.
I haven't played around with embedding Google Maps before (I generally go straight to the API for stuff like this). I tried a couple of approaches:
I figured maybe the embed syntax would be the same as the static maps api. So I grabbed a static maps URL, copied the markers param from that and tried sticking it into the iFrame URL. This didn't work so much.
I created a Google MyPlaces and customized the marker to use the one your provided. This created a Test map which had the appropriate marker icon. I then grabbed the embed code and stuck it on a test page and voila!
Actually I had the same problem but didn't use any of the methods above and thought I share:
If you only want a marker as I did but don't want to use API then simply fool google into thinking you want a route planned using the GET tags "saddr" and "daddr"
"saddr" defines your start location (post code , street name+ number, whatever)
ONLY define saddr and leave out daddr and google maps will by default still show the marker for "A" (your start location) exactly where you want it , all in iframe without API.