Link to Google Streetview using Lat/Long - language-agnostic

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.

Related

Google Maps URL with pushpin and satellite basemap

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}

Mapbox or Google Maps. Is this possible?

I have a custom map from a client. They want to either use Mapbox or google maps to add markers to it. The problem is they've customized how the world map actually looks. It doesn't show on the map image attached, but they cut off Alaska, and want to show it directly under Texas as a floating state. They also want to show so other states in an odd order. To the right of Alaska they want Hawaii, Puerto Rico, US Virgin Islands.
Two issues here:
1) Can this be done? I can't find any information about cutting pieces of a map up by moving states around.
2) If I CAN do this, will the geocoding still work for the map? Cause now Alaska is way the heck down there.
As far as I know, yes to both of your issues.
Now, to answer your issues:
1) Can this be done? I can't find any information about cutting pieces of a map up by moving states around.
As discussed in Translate your project from Google to Mapbox, you have options to customize maps and features. Then, any customized project created in the Mapbox Editor or uploaded from Mapbox Studio Classic will have a Map ID. Use the Map ID when initializing the map to add it as the active layer.
2) If I CAN do this, will the geocoding still work for the map? Cause now Alaska is way the heck down there.
Yes, geocoding will still work. With Mapbox, L.mapbox.geocoder() will gladly geocode your addresses.
Please try going through the given documentation for more information and for sample codes. Hope that helps!

Current Location in Google Maps using only a URL

So I would like to use a URL to retrieve and display ONLY the users CURRENT LOCATION.
For example: A user with a smartphone (iPhone, Android, etc) opens a link [http://maps.google.com/CURRENTLOCATION] on their phone, and it shows their current location on the user's device in either Google Maps app or browser, as reported by their GPS/wireless location. The actual link itself should should remain static, and display the location wherever they are.
Is this possible?
Thanks in advance!
If you have the lat/long coordinates (which I suppose you get through the gps/wireless device), you can use something like this:
http://maps.google.de/maps?q=loc:48.0000,9.000
which opens the Google Maps website with the coordinates N48.0 E9.0 (as decimal coords) centered.
Or, if you need a static map (and not a full fledged JavaScript map), use this link and adjust the values inside the URL:
http://maps.google.com/maps/api/staticmap?center=48.00,9.00&zoom=14&size=512x512&maptype=roadmap&markers=color:blue|48.0,9.0&sensor=true
Valid values for the arguments are:
for maptype: roadmap, terrain, satellite
for zoom: 1 to 20
This is discussed front and center in the Google Maps geolocation API: Detecting the User's Location
According to the documentation, the user will need using an HTML5 equipped browser for this to work. You will need to write the Javascript which looks pretty vanilla.
Edit: This only works if you are using your own domain and have implemented the Maps API (which is really simple), not Google's own maps.google.com

Google Maps: Traffic on top of Custom Map

I want to add traffic information to my custom map. Currently I'm using a Tile Layer Overlay on my Google Map to display custom map tiles. When I try to add GTrafficOverlay to my map, my custom map tiles display above the traffic information. Is there any way to display the traffic above my GTileLayerOverlay?
(Using the JavaScript api)
You should be able to do this in V3. Take a look at this sample: http://code.google.com/apis/maps/documentation/v3/overlays.html#ImageMapTypes
I tried this out and wasn't able to find a solution to the problem. There is nothing in the GTrafficOverlayOptions and I couldn't find anything in the references about the z-order of this stuff. I have suspect that this isn't possible.
Would love to see an alternative answer showing that I am wrong.

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.