Google Maps URL with pushpin and satellite basemap - google-maps

Background Information
I can form a simple valid Google Maps URL that has a pushpin on a coordinate like so using the query parameter:
https://www.google.com/maps/search/?api=1&query=47.5951518,-122.3316393
Direct link
Similarly, I can form a URL with a satellite image of the same location using the center and basemap parameters:
https://www.google.com/maps/#?api=1&map_action=map&center=47.5951518,-122.3316393&zoom=17&basemap=satellite
Direct link
Desired End Result
What I'd like to have is a satellite image like in the second URL with a pushpin. The result of this can be seen by using the first URL and pressing the 'Satellite' button on the bottom left of the map. From what I can tell, the basemap and query parameters may not be used together like below, but I'd love to be proven wrong.
https://www.google.com/maps/search/?api=1&query=47.5951518,-122.3316393&basemap=satellite
Desired end result:
Direct link
I need to be able to construct the URL with a dynamic set of coordinates. I haven't found a way to manipulate the parameters in order to accomplish this.
Note: the final URL I included is an "unpacked" URL generated by Google Maps and not constructed by hand. I haven't found a way to manipulate it the way I want, and even if I could, I'm sure it's not the correct way to solve this problem.

You are right in that this can't be done with the new Google Maps APIs. The "Search" URL scheme allows pinning but no satellite view, whilst the "Display a map" scheme allows satellite views but no pinning.
However, it is possible get both pinning and satellite views by using this old, no-official-documentation, scheme:
http://maps.google.com/maps?t=k&q=loc:47.5951518+-122.3316393
The t parameter used to work with a number of different values but only two seem to currently still work:
t=m - Normal map view
t=k - Satellite view
Note that unofficial documentation for the other parameters can be found here. Some of these may also still work.

For anyone still looking for a solution in 2022, you can use the following undocumented URL scheme:
https://www.google.com/maps/place/{lat},{lng}/#{lat},{lng}/data=!3m1!1e3
This is the best solution I could find that mimic the plan-limited query URL scheme:
https://www.google.com/maps/search/?api=1&query={lat},{lon}

Related

Google map zoom parameter in url not working

Why doesn't google map z (zoom) parameter work inside the url?
I' ve searched over so I got few solutions for sending zoom parameter in google map url but based on the old posts (stackoverflow) which deal with the zoom level within the url it seems that this functionalities do not work anymore.
I've used the following z parameter but it's not working:
http://maps.google.com/?q=38.6531004,-90.243462&z=12
Below is the link where they have mentioned z parameter for zoom level
link
For those who do not want to read,
this works (z range:[1-20]):
https://maps.google.com/?q=38.6531004,-90.243462&ll=38.6531004,-90.243462&z=3
There is no documentation that covers this problem. However, there are few hacks.
The link that you have provided,
URL (stackoverflow):What parameters should I use in a Google Maps URL to go to a lat-lon?
Will not help you with getting the desired google maps zoom level inside a url
The following examples which have been working for quite a while DO NOT WORK anymore (they work but without getting the desired zoom level)
Examples:
http://maps.google.com/?q=38.6531004,-90.243462&z=3
http://maps.google.com/?q=38.6531004,-90.243462&zoom=3
http://maps.google.com/maps?q=Scottish+Rite+Hamilton+ON&loc:43.25911+-79.879494&z=15
Instead, you can get the zoom level easily by trying the following examples:
https://www.google.com/maps/#38.6531004,-90.243462,9z
https://maps.google.com/?ll=40.7060471,-74.0088901&z=3
(Note: after clicking on google maps you will get a gray marker which appears and quickly disappears)
However the above URL's will not give you a static pinpoint for the specified lat&long.
There is a "hack" on how to get a fixed pinpoint (red marker pin) and that is by giving the q attribute (represents the search query) and the II attribute(latitude and longitude of the map centre point) along with the z (zoom attribute)
Example (with the OP coordinates):
https://maps.google.com/?q=38.6531004,-90.243462&ll=38.6531004,-90.243462&z=3
If you want to change the zoom level just change the value of 'z'.
After searching the web I found that only this website:
https://moz.com/blog/new-google-maps-url-parameters
deals with google maps parameters/attributes/arguments, where things actually still work. If anyone want's more functionalities within the url, then this is the site to check.
Zoom intervals explained (https://developers.google.com/maps/documentation/static-maps/intro#Zoomlevels):
The following list shows the approximate level of detail you can
expect to see at each zoom level:
1: World
5: Landmass/continent
10: City
15: Streets
20: Buildings
This works as of 5 Aug 2018
http://www.google.com/maps/place/<lat>,<lng>/#<lat>,<lng>,<zoom>z
For example
http://www.google.com/maps/place/49.46800006494457,17.11514008755796/#49.46800006494457,17.11514008755796,7z
As of 04/2020 ...."because google is always changing and evolving"
In complement to Eugen Sunic comments above, and an alternative update to the Solution.
When Logged in to google and getting map data from the google generator, it is not the same as copying the URL from the browser window (which my may be manipulated to load different zooms trough the various alterations, html, Css and script tricks).
But in the below, keep in mind that Your address info may need to be part of the google array of database, eg you have some address map info linked to your account, images, business name, etc. or not... maybe just typed in for a quick map search with a pin-point... the later I don't know.
Also the below is not some Google API pay per 1k clicks thing, which is more geared to the commercial development end of google tracking heat maps, etc. So if you just need a simple solution and certain zoom and marker to work..then you might try the below.
When logged in too your Google account (maybe not) and showing your location marker on the map screen...
Choose the zoom detail of the map you want to appear in your web page. eg Whole US, State views, City, Street (by clicking the + or - zoom feature).
Then go to the hamburger menu to the left, and look down the list for "Share or Embed Map" and the popup window should load the same zoom level of the map! Do not try to change the zoom in the popup window feature, it wont work to change the link code but will change the pop up windows zoom of the map. In short, the embedded link code is preset and will not change in the popup.
Above this popup window of the map there will be two options at the top (Share and Embed) button/link selections.
Click on the Embed link/button and it should generate the code for the zoom you previously chose.
Lastly, copy the code, paste it into your web page and TEST!
As far as I can tell, There is no altering this code as the others suggested above, changing(z=3, 9z, etc) as the code is entirely different. But it will allow you to get the zoom you need "if the google code generator or procedure does not change".
But the zoom level was altered and good enough for me when I figured the process out. Changing it to other zooms is another can of code.

Approaching a map based selection

I have a map of several counties I need to turn into a county select menu (i.e clicking Leicestershire will select Leicestershire.
I am using a php built system that this map will need to return the appropriate value to. I am thinking this will be a get in the url, checked for valid values in the backend.
How would you approach this? A html co-ordinate map? Some sort of Javascript? Flash?
I am aware all those solutions have one drawback or another. Does anyone know a better way of doing this? Or an existing opensource project?
Just an idea, if I read your problem correctly: I would personally use the Google Maps API for this. Plot each county onto your custom Google Map, then when you click each marker an info window could appear with "Select this County". Click the link and pass a value through the URL to your PHP script.
Used a html map system. Dreamweaver made it easy (first time I've used the design screen seriously)

Link to Google Streetview using Lat/Long

I'm trying to make an app that links to Google streetview using latitude/longitude coordinates, and shows a streetview of the nearest road. This is coming from a fairly small and well covered area, so there isn't going to be any coordinates in the middle of the ocean.
Is there a published API showing the get parameters you need to link directly to streetview?
You may be interested in checking out the following reference, which describes all the known parameters that can be passed to maps.google.com, including Street View parameters:
asnsblues: Google Map Parameters
While this is not an official API, I think it is fair to say that these should be quite reliable, since they are the same parameters used for the permanent links in Google Maps.
With this, you should be able to construct something like the following:
http://maps.google.com/?cbll=40.714103,-74.006206&cbp=12,20.09,,0,5&layer=c
If you want to extract the raw jpegs from the Streetview service this can be done fairly easily. The technique is discussed here:
http://jamiethompson.co.uk/web/2010/05/15/google-streetview-static-api/
XML metadata for a panorama can be gained from the following request
http://cbk0.google.com/cbk?output=xml&ll=[LAT,LNG]
which gets you something like this:
<panorama>
<data_properties image_width="13312" image_height="6656" tile_width="512" tile_height="512" pano_id="sLaiF6Jex7mJmNol7tdOoA" num_zoom_levels="3" lat="51.495090" lng="-0.146971" original_lat="51.495098" original_lng="-0.147000">
<copyright>© 2010 Google</copyright>
<text>Eccleston Pl</text>
<region>London, England</region>
<country>United Kingdom</country>
<data_flag>1</data_flag>
</data_properties>
<projection_properties projection_type="spherical" pano_yaw_deg="201.78" tilt_yaw_deg="92.06" tilt_pitch_deg="1.75"/>
<annotation_properties>
<link yaw_deg="204.7" pano_id="CeutxcyB2V74lfN_fJwRww" road_argb="0x80ffffff">
<link_text>Eccleston Pl</link_text>
</link>
<link yaw_deg="24.7" pano_id="t_mnKSugTLrQTEnJplXQ3A" road_argb="0x80ffffff">
<link_text>Eccleston Pl</link_text>
</link>
</annotation_properties>
The pano_ids can then be used to get thumbnails or high resolution tiles from the streetview API
Thumbnail
http://cbk0.google.com/cbk?output=thumbnail&w=416&h=208&panoid=sLaiF6Jex7mJmNol7tdOoA
Tile
http://cbk0.google.com/cbk?output=tile&panoid=sLaiF6Jex7mJmNol7tdOoA&zoom=4&x=0&y=3
Do you mean something like this?
The following is a link to a streetview picture at coordinates 40.437, -79.962 (lat,lon):
http://maps.google.com/maps?f=q&hl=en&geocode=&sll=40.437965,-79.96253&sspn=0.007104,0.020084&layer=c&ie=UTF8&ll=40.437361,-79.960599&spn=0.007104,0.027122&z=16&cbll=40.433975,-79.962101&cbp=2,142.0851621378081,,0,3.3364732946064946
I'm not sure why the coordinates are repeated a few times, I suspect it might have something to do with viewing direction and the like. I haven't checked whether this works for other coordinates. Hope this helps.

How could a share a Google map mashup with my own datapoints and links back to my site?

I currently have a map mashup that has locations that I'm populating from my own database. A few users would like to also show that map on their site(s). I'd like to give them the ability to do that, but would like to retain the actual functionality of the map on my own site: like add "stuff" to places on the map through my a web form on my site. I could open the entire API to allow them to create their own form along with the data points, but most of the people wanting to put up the map aren't developers, they are just enthusiasts that have put together a personal page that they want to spice up.
I was thinking I could just provide a JavaScript of some kind that they could then take to place on their site, or maybe an IFRAME of some type, or...any ideas? Anyone implemented this? TIA.
I haven't done anything like this myself, but I think your idea to utilise an iframe is on the right track. In fact, this is how Google Maps generates its embed code.
Your app will need to generate a URL with all relevant Google Map parameters such as bounds, zoom level as well as your application-specific params. Any event that triggers the map to re-draw (drag, zoom, etc.) will generate a new URL.
If you try the embed link in Google Maps as an example, it generates a URL that looks something like this:
http://maps.google.com/maps?f=q&source=s_q&sll=45.434035,12.339057&sspn=0.003294,0.004812&ie=UTF8&ll=45.432724,12.338966&spn=0.006588,0.009624&t=h&z=17
This URL can then be wrapped up in an iframe which your end users can place on their web pages.
Re: resizing
Yes, it's possible to dynamically resize it if width/height is part of your application params that generates the embed code. Again using Google Maps as an example:
<iframe
src="http://maps.google.com/maps?f=q&source=s_q&sll=45.434035,12.339057&sspn=0.003294,0.004812&ie=UTF8&ll=45.432724,12.338966&spn=0.006588,0.009624&t=h&z=17&output=embed"
width="(width-param)" height="(height-param)"></iframe>
If you mean resized by user, after it's been displayed, I'm not sure.. most likely, yes.

Do i need use google maps api only to embed litle map with route calculator/display for only one destination?

Well i want to upgrade contact page with dynamic map showing location and give oportunity to calculate route for comapny headquatters. Id it necessery for such simple task use Google api? i mean here generating akey etc? Fo i have any other alternatives to google maps?
There's really no reason to mess with the API at all unless you need to customize the appearance or behavior of gmaps. Why not just use an iframe with a url of:
http://maps.google.com/?q=[you-url-encoded-address-here]
or better yet, set up a textbox and a 'get directions' button to redirect that frame to:
http://maps.google.com/maps?saddr=[their-address]&daddr=[your-address]
edit: this works well in modal dialog if you don't want the google logo sticking out like a sore thumb in your pageflow
You could probably embed directly with a specific URL that will configure it to have the destination you want.
By the way, well written answers are much more likely to receive useful responses here.
You could consider http://www.openlayers.org/ as an alternative to google maps.
In fact open layers can be used to add a Google map, or an OpenStreetMap map or a Bing map, etc.