How to get google static map with scale 2 and returns 2048x2048 pixels without Premium Plan - google-maps

When I get google static map with scale is 2, I only get map size with maximum is 640px. How can I get google static map with scale is 2 and maximum image size up tp 1024 without upgrade account to Premium Plan???

https://maps.googleapis.com/maps/api/staticmap?center=0,0&zoom=2&size=1024x1024&scale=2
This returns a map of size 1024x1024 with scale 2.
The documentation states that you can get 1280 x 1280 without Premium Plan.

Related

The Google Maps Platform server rejected your request. Invalid request. Invalid 'size' parameter

I have a link to google street view in a web mapping app that is tied to a dynamic address attribute {SitusAddress}
The link is embedded as an img src to the same location but as a small image on the web page
img src='https://maps.googleapis.com/maps/api/streetview?size=270x150&location=${SitusAddress}&fov=120&pitch=-5
notice the size parameter at 270x150. This makes a rather small image. When the image is clicked, I want a nother tab to open with the same street view but in google maps taking up the entire page such as what would happen if uyou were in google maps and clicked street view. I tried it without a size parameter and with size =100%x100%
<hr><a href=https://maps.googleapis.com/maps/api/streetview?size=100%x100%&location=${SitusAddress} target='_blank'>
How can I fulfill the size param that's not a static size?
You need to dynamically calculate the size of the image needed in pixels and provide that pixel based size to the API.
Per the documentation size is required and is in pixels:
size specifies the output size of the image in pixels. Size is specified as {width}x{height} - for example, size=600x400 returns an image 600 pixels wide, and 400 high.

Showing large image at original size on mobile devices

I have a very high resolution 'cartoon' road map with a number of locations also drawn on. Users can click on locations drawn on the map to navigate to related pages.
The map is not drawn to scale at all hence I decided to map co-ordinates on the image to create the required links rather than as a GMaps overlay or similar. This works assuming the user has a desktop which shows the image to the full width of a PC monitor, but I'm struggling with how to serve such a high resolution (approx 4000px x 3000px) image in a way which is intuitive for mobile users to navigate and still be able to see sufficient detail (ie. showing the map at original size but with perhaps pinch/drag functionality similar to an actual GMap). Any suggestions?

Get total degrees latitude/longitude displayed on a Google map when world wraps- Javascript v3 API

I am writing some code which clusters markers on a Google map. The clustering algorithm relies on knowing how many degrees latitude and longitude are currently visible to the user, as I break the map into a grid of n/map_pixels_width x n/map_pixels_height squares and need to know how many degrees of lat/lon are in each square to know which square each marker point belongs to.
Under normal circumstances where the map does not wrap this is relatively easy to calculate using getBounds() on the Google Map object and doing the calculations to figure out the latitudinal and longitudinal distances between the returned North-East and Sout-West points. Where I'm running into issues is where the map is zoomed out to the extent that it wraps the entire Earth > 1 times. For example, I can zoom out the map so that the entire Earth is "tiled" 5 times over which equates to 360 * 5 = 1800 longitudinal degrees and, but then the call to getBounds() no longer provides useful information:
m.getBounds().getNorthEast().lat()
88.31833020528785
m.getBounds().getNorthEast().lng()
180
m.getBounds().getSouthWest().lat()
-88.5485785544835
m.getBounds().getSouthWest().lng()
-180
Basically, the longitudes getBounds() reports are just the min and max for one whole globe which says nothing about how many times the Earth is repeated. Although Google Maps doesn't tile the map vertically (it just inserts gray filing space if zoomed out far enough), I have conceptually the same problem -- I need to know how many total degrees of space the vertical area would consume.
Is there a way to get the total number of visible longitudinal degrees?
So based on this answer to another question, I found a (hackish) way to solve this. Basically, the Google Maps OverlayView class has a getProjection() method returning a MapCanvasProjection object, which in turn has a getWorldWidth() method which returns the width of the world at the current zoom level in pixels. So the way to solve the problem then is to:
Add a dummy OverlayView to the map that doesn't actually present an overlay.
Get the overlay's projection.
Get the world width from the projection.
Calculate the number of visible longitudinal degrees as pixel_width_of_map_element / world_width_in_pixels * 360
It would be better if there were a way to do this without creating a dummy overlay, but this method seems to work.

Change DPI with Javascript Google Maps Api

I need to create a 80x80cm (or 33inchx33inch) map with Google Maps. This map will be printed and exhibited, so the higher DPI the better. Actually, in printing, a 300DPI is the minimum.
Now, I'm using the Javascript API in order to create the map I want :
- change the mapOptions with an array of styles with various colors
- add a Transit Overlay in order to have the map of the urban trains added over the map (see this aautar.digital-radiation.com/blog/?p=3761)
- add polygons as a link to KML URL to one of my maps
If you want to see the result : http://www.tellnet.fr/blog/test.html (it's very long to download since it's a 5000x5000 picture).
The problem is that, at the Scale level I want (with not too many details), the big picture I get is a 5000x5000, which gives a 150DPI only printable file.
To obtain a 10000x10000 picture as I would to print a 80x80cm map at 300 DPI, I need to :
- either my map zoom once, but then I've got soooo many details, that will be printed super tiny
- or change the DPI of the map, asking Google Maps to double it.
It would basically give me the same map at the same scale, but with thinner lines and texts (making a 10000x10000 pictures).
I know this is possible with the static maps Api, change the Scale value to 2 (see https://developers.google.com/maps/documentation/staticmaps/?hl=fr#scale_values).
The problem is that, this is the static maps API, so please can someone tell me if :
- it's either possible to do all the above things with the static API
- or change the "scale" value (ie the DPI value) with the Javascript API.
I also tried to change the meta viewport value, but this only works with mobile devices... (I searched for all solutions, now I'm blocked!)

Google street view URL

Hi I have the address of a property and my application can launch a browser to go to http://maps.google.com?q=searchStringHere. If a good match is found it will take it directly there. Is there any thing I can append to the url to make it switch to streetview without having the exact coordinates? I dont't want to code any javascript or flash.
Building a Google Street View URL
Basic Google Map URL
http://maps.google.com/maps?q=
q= Query - anything passed in this parameter is treated as if it had been typed into the query box on the maps.google.com page.
Basic url to display GPS cords location
http://maps.google.com/maps?q=31.33519,-89.28720
http://maps.google.com/maps?q=&layer=c
layer= Activates overlays. Current options are "t" traffic, "c" street view. Append (e.g. layer=tc) for simultaneous.
http://maps.google.com/maps?q=&layer=c&cbll=
cbll= Latitude,longitude for Street View
http://maps.google.com/maps?q=&layer=c&cbll=31.33519,-89.28720
http://maps.google.com/maps?q=&layer=c&cbll=31.335198,-89.287204&cbp=
cbp= Street View window that accepts 5 parameters:
Street View/map arrangement, 11=upper half Street View and lower half map, 12=mostly Street View with corner map
Rotation angle/bearing (in degrees)
Tilt angle, -90 (straight up) to 90 (straight down)
Zoom level, 0-2
Pitch (in degrees) -90 (straight up) to 90 (straight down), default 5
The one below is: (11) upper half Street View and lower half map, (0) Facing North, (0) Straight Ahead, (0) Normal Zoom, (0) Pitch of 0
This one works as is, just change the cords and if you want to face a different direction (the 0 after 11)
http://maps.google.com/maps?q=&layer=c&cbll=31.335198,-89.287204&cbp=11,0,0,0,0
For more Google Street View code interpertation
Unfortunately not - there's no simple answer, based on the address.
Firstly, the list of parameters for the Google Maps site is documented here, so you can use that as your starting point.
The easy part is that you need to select the streetview layer "&layer=c".
However, before anything will display in that layer, you need to specify where your view is. You set the position by the latitude and longitude in cbll and the angle of the camera with some options in cbp.
To get the latitude and longitude from the address, you need to use a geocoding service, like the google maps api.
However, this will only get you a street view close to the address. In addition to knowing where the street view needs to be from, you also need to know which angle to point the camera at - this will be different for every address, depending on where the nearest point the StreetView camera took a photo from was, so it's not easy to do automatically (with any information that I know is available...)
UPDATE 07/2019:
Solution of 10/2018 still works for me as of now, but I have found an official documented way to construct the Street View URL:
Forming the Street View URL
https://www.google.com/maps/#?api=1&map_action=pano&parameters
Parameters
map_action=pano (required): Specifies the type of view to display. Maps and Street View share the same endpoint. To ensure a panorama is displayed, the action must be specified as pano.
One of the following URL parameters is also required:
viewpoint: The viewer displays the panorama photographed closest to the viewpoint location, specified as comma-separated latitude/longitude coordinates (for example 46.414382,10.013988). Because Street View imagery is periodically refreshed, and photographs may be taken from slightly different positions each time, it's possible that your location may snap to a different panorama when imagery is updated.
pano: The specific panorama ID of the image to display. If you specify a pano you may also specify a viewpoint. The viewpoint is only used if Google Maps cannot find the panorama ID. If pano is specified but not found, and a viewpoint is NOT specified, no panorama image is displayed. Instead, Google Maps opens in default mode, displaying a map centered on the user's current location.
The following URL parameters are optional:
heading: Indicates the compass heading of the camera in degrees clockwise from North. Accepted values are from -180 to 360 degrees. If omitted, a default heading is chosen based on the viewpoint (if specified) of the query and the actual location of the image.
pitch: Specifies the angle, up or down, of the camera. The pitch is specified in degrees from -90 to 90. Positive values will angle the camera up, while negative values will angle the camera down. The default pitch of 0 is set based on on the position of the camera when the image was captured. Because of this, a pitch of 0 is often, but not always, horizontal. For example, an image taken on a hill will likely exhibit a default pitch that is not horizontal.
fov: Determines the horizontal field of view of the image. The field of view is expressed in degrees, with a range of 10 - 100. It defaults to 90. When dealing with a fixed-size viewport, the field of view is considered the zoom level, with smaller numbers indicating a higher level of zoom.
Example 1: Uses only a viewpoint to specify location.
https://www.google.com/maps/#?api=1&map_action=pano&viewpoint=48.857832,2.295226&heading=-45&pitch=38&fov=80
Source: https://developers.google.com/maps/documentation/urls/guide
(scroll to the bottom for Street View URLs)
Update 10/2018
The GET API (see Haygood's answer) seems to be outdated but some calls still seem to work.
Base URL:
changed to http://www.google.com/maps (map.google.com/maps still works but redirects)
Parameters:
q: is ignored, can be skipped
For more Google Street View code interpertation
layer: The parameter must be set to c (t is no more supported and breaks it)
cbll: latitude and longitude (unchanged)
cbp: only parameter 2 (rotation angle) and 5 (pitch) are still supported
is ignored, can be 0 or empty string
Rotation angle/bearing (in degrees)
is ignored, can be 0 or empty string
is ignored, can be 0 or empty string
Pitch (in degrees) -90 (straight up) to 90 (straight down)
Updated examples: http://www.google.com/maps?layer=c&cbll=31.335198,-89.287204
or http://www.google.com/maps?layer=c&cbll=31.335198,-89.287204&cbp=,30,,,20 with rotation 30 and pitch 20.
You can get the values by pressing the link button at the top of the street view.