Google Maps Static API - Custom zoom with markers - google-maps

I am creating an application that downloads images from maps using the Google Maps Static API. I would want to decide the zoom level when having markers on the map (right now the zoom is set automatically so that all markers are shown in the image). Does anyone know if this is possible?

Right now the zoom is set automatically so that all markers are shown in the image
You are halfway there. Once done, get the resulting the zoom level: map.getZoom();
However, I think your app violates Google's terms as it is forbidden to copy their content.

According to the documentation, you can use the center and zoom parameters to configure the map (they aren't required with markers):
Location Parameters
center (required if markers not present) defines the center of the map, equidistant from all edges of the map. This parameter takes a location as either a comma-separated {latitude,longitude} pair (e.g. "40.714728,-73.998672") or a string address (e.g. "city hall, new york, ny") identifying a unique location on the face of the earth. For more information, see Locations below.
zoom (required if markers not present) defines the zoom level of the map, which determines the magnification level of the map. This parameter takes a numerical value corresponding to the zoom level of the region desired. For more information, see zoom levels below.
example URL:
https://maps.googleapis.com/maps/api/staticmap?center=42,-72&zoom=5&size=400x400&markers=color:blue%7Clabel:S%7C11211%7C11206%7C11222&format=jpg
resulting image:

Related

Get static image from Google map for given area

I know that Google Maps provides an API for getting static images:
https://developers.google.com/maps/documentation/static-maps/intro
However that API gets as input a center point, zoom level and output image size.
In my case, I need an image that fits a given area taking as input the NW (top-left) and SE (bottom right) coordinates describing the rectangle of my area. I don't see that option within Google Maps API, so I'm wondering if there is another way to accomplish this.
You can omit the center and zoom parameters if you specify at least one marker. In this case you can show a certain area with a marker.
For example, I have bounds of Barcelona in Spain:
41.320004,2.069526 and 41.469576,2.22801
I can easily calculate the center position of the bounds:
41.39479,2.148768
Now, let's put a marker in the center of bounds and use the visible parameter of Static Maps API to specify NW and SE.
visible (optional) specifies one or more locations that should remain visible on the map, though no markers or other indicators will be displayed. Use this parameter to ensure that certain features or map locations are shown on the Google Static Maps API.
https://maps.googleapis.com/maps/api/staticmap?size=600x400&markers=icon%3Ahttp%3A%2F%2Fwww.google.com%2Fmapfiles%2Farrow.png%7C41.39479%2C2.148768&visible=41.320004%2C2.069526%7C41.469576%2C2.22801&key=api_key
Code snippet
<img src="https://maps.googleapis.com/maps/api/staticmap?size=600x400&markers=icon%3Ahttp%3A%2F%2Fwww.google.com%2Fmapfiles%2Farrow.png%7C41.39479%2C2.148768&visible=41.320004%2C2.069526%7C41.469576%2C2.22801&key=AIzaSyDztlrk_3CnzGHo7CFvLFqE_2bUKEq1JEU&signature=WkICJTRmmI1EgDK2VJI4l9lt3qA=" title="" />
As a result, you have an image with specified area. I think you can even go further if you create a transparent png file for marker icon.
Hope it helps!

How to split markers on Google Static Map on same address?

In My application I have to show split of markers which means all markers should be visible. If one marker geo distance is longer than others it should show like below.
In Google Dynamic Map API which is possible by “Spiderfier”. Refer the link below and below image.
http://jawj.github.io/OverlappingMarkerSpiderfier/demo.html
Like this option, I have to split of all markers in Google Static MAP API.
Any possibilities there to visible all markers ?
Static Map URL:
http://maps.googleapis.com/maps/api/staticmap?sensor=false&channel=Resivalue&scale=2&center=29.900598698735365,-95.69396430030821&zoom=13&size=1300x500&maptype=roadmap&markers=color:green%7Clabel:S%7C29.89357,-95.68815999999998&markers=color:pink%7Clabel:1%7C29.893167,-95.68737599999997&markers=color:pink%7Clabel:2%7C29.893904,-95.688424&markers=color:pink%7Clabel:3%7C29.892301,-95.68776500000001&markers=color:pink%7Clabel:4%7C29.892343,-95.68866200000002&markers=color:pink%7Clabel:5%7C29.894404,-95.689029&markers=color:pink%7Clabel:6%7C29.893235272621563,-95.68611836505124&markers=color:pink%7Clabel:7%7C29.892402,-95.68687699999998&markers=color:pink%7Clabel:8%7C29.891934,-95.688918&markers=color:pink%7Clabel:9%7C29.919640547998576,-95.72656616430663
As stated here
Google Static MAP API Disadvantages :
The main disadvantage is the lack of a map interactivity – if we
need a map to scale, move or if we need to roll down a window after
clicking on a marker; Google Static Maps is not a solution for us.
URL address of a map has a restricted length (2048 symbols) which
sometimes may make impossible to present all needed content on a
map.
Limits also apply in the case of own images markers placing on a map
– in this case it is 4096pixels (64 x 64 px).

How to zoom to the pointer in a google map

I have a google map in an iframe in which, I am passing the longitude and latitude.
What I want is,
I want show the map zoomed to the pointer corresponding to the longitude
and latitude given.
Fiddle
In the given fiddle, user have to scroll the map to right, to see the marker. Instead I want to show the marker to the user, when the map loads with better zoom.
I will have similar maps like this with different longitude and latitude in different pages. I want to apply this all those maps.
Your "ll" parameter is the one centering the map. If you give it the same value as the "q" parameter, your map will be centered on that point.
https://maps.google.co.in/maps?[]...q=38.89205,+1.35275&
[...]ll=38.89205,+1.35275&output=embed"
Here is a jsFiddle: http://jsfiddle.net/D4Y4r/
If you wish to zoom in, you can increase the value of the "z" parameter.
Quick edit: this page might provide you some insight on the URL parameters http://asnsblues.blogspot.in/2011/11/google-maps-query-string-parameters.html

Google Maps default zoom level

I created a public map using my Google Map. I want to set a default zoom level, but it is not saved. Is this possible?
Also, is it possible to change the list of place markers?
the reference map that you supply (quebec summer festival) is called by the URL: http://maps.google.com/maps/ms?source=embed&hl=en&geocode=&ie=UTF8&msa=0&msid=112492115201367239282.0004609e0fcc239c4f792&ll=46.81084,-71.217113&spn=0.02056,0.038624&z=15
notice that the last parameter "&z=15" defines the zoom level (in the embed map code, "&z=15" becomes "& a m p ; z = 1 5" [remove spaces between letters]). if you change this you can increase or decrease the zoom level. if you suppress the zoom level, googlemaps will automatically calculate a zoom level when displaying said map. NORMALLY this leaves some of your map outside the frame.
so, just by supplying the URL with the desired zoomlevel you have solved your problem. this works very well with static maps. if you have a dynamically generated map (from a database, for example), the fastest solution is to put 2 markers (top left and bottom right corners) slightly outside your boundary box. this will force automatic zoom in the desired amount (hopefully).
Not using API just made a map points using my GMail account and made it public, like the following site:
http://maps.google.com/maps/ms?source=embed&hl=en&geocode=&ie=UTF8&msa=0&msid=112492115201367239282.0004609e0fcc239c4f792&ll=46.81084,-71.217113&spn=0.02056,0.038624&z=15
Nothing is saved by a web page. HTML browsing is stateless. If you want to save some information you will need to use similar trick as any other web applications. E.g. putting it in cookie and the setting the zoom level using the information in the cookie when you initial the page.

google maps : put markers all over visible section on Google map display

I want to show limited numbers of markers(let's take 50 or so...) at all zoom level and in a manner that markers covers all entire Google map display.
So, If I am viewing whole world in map, it will show markers all over the world not to exceed a certain number, and the if I zoomed to USA it will only show previous number of markers only inside USA.
And then again if I moved to Canada , then the map should show markers of Canada only.
I am not able to
- put makers on visible region over the map on limited distances
i.e. all the visible markers maintaining somewhat some distance from each other.
You might want to look into 'clustering' or 'bunching' the points into one. It doesn't do exactly what you are describing, but it will effectively limit the number of markers you have when you are zoomed out, and 'uncluster' them once you zoom in.
There are quite a few ways (all third party - the Google API doesn't support it yet), you could have a look here at one called ClusterMarker: http://googlemapsapi.martinpearman.co.uk/articles.php?cat_id=1.
You should use a marker manager!
See http://code.google.com/p/gmaps-utility-library-dev/ and http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/