Bing Maps - Determine max zoom level using REST imagery API - zooming

Can someone confirm to me that this can be used as an identifier for no tiles at certain zoom levels. If I issue the following request: "http://ecn.t2.tiles.virtualearth.net/tiles/a0030300.jpeg?g=12276" in the response headers there is going to be entry "X-VE-Tile-Info=no-tile"
This can be taken as an identifier for the empty tile (image width camera)?
Also I wonder if there is a call to REST API that will use tilePositionX and tilePositionY instead lat, lon for this request: https://dev.virtualearth.net/REST/V1/Imagery/Metadata/Aerial/40.714550167322159,-74.007124900817871?o=xml&zl=20&key={BINGAPI_KEY}

Corrent, that header can be used to identify if imagery is not available for that tile.
The imagery metadata service only works with latitude/longitude coordinates and not tile coordinates. The only way to check if imagery is available for a specific tile coordinate is to request the image can check the header (basically a rest service).

Related

Different default viewports in Google Static Streetview API vs Google Maps Embed API

I'm looking for a way to get the default heading in the Google Maps Streetview Embed with the same accuracy/heading as the static Streetview.
For a project I'm using the Google Maps static Streetview API to create a snapshot/front facing view of an address. The way I do this is to first find the address LatLng with the Google GeoCode API, using the full address (streetname+house_number+house_number_addition+zipcode+city). With the latLng I then call the Static streetview API to fetch a snapshot of this location.
https://maps.googleapis.com/maps/api/streetview?size=900x600&location={$latLng}&key={$key}"
As you can see there is no heading param specified so the API determines the best possible heading based on the given LatLng, as specified in the API docs.
The result is spot on for 99% of the cases, in which the house is almost perfectly centered in the streetview snapshot.
The Google maps streetview embed has a very different result. The steps leading up to the creation of the embed URL are identical (find the latlng based on the full address, and use the LatLng as the location in the embedcode)
https://www.google.com/maps/embed/v1/streetview?key={$key}&location={$latLng}"
resulting in the iframe HTML
<iframe src='{https://www.google.com/maps/embed/v1/streetview?key={$key}&location={$latLng}"}' width='600' height='450' frameborder='0' style='border:0;' allowfullscreen='' aria-hidden='false' tabindex='0'></iframe>
In this case the heading or camera direction is in many (not all) cases almost facing opposite of the targeted house. Of course this can be adjusted using the heading param, but it's strange that both streetview API's differ so much in the chosen heading.
After some more digging I found the answer here. The solution is to first use the Directions API to navigate to the given location, which sets the heading facing the location. Then use the getPanoramaByLocation method of the StreetviewService to determine the correct heading.
So instead of constructing the embed code serverside, the best approach seems to create the Streetview in the frontend using the Google Maps API.

Whats the difference between location and viewport coordinates when geocoding with google API v3

I am new with using the Google maps geocoding API. I gave it an address and have a few different coordinates in the response. Why are there different coordinates?
More on Viewports: https://developers.google.com/maps/documentation/geocoding/intro#Viewports
"In a geocoding request, you can instruct the Geocoding service to prefer results within a given viewport (expressed as a bounding box). You do so within the request URL by setting the bounds parameter. Note that biasing only prefers results within the bounds; if more relevant results exist outside of these bounds, they may be included.
The bounds parameter defines the latitude/longitude coordinates of the southwest and northeast corners of this bounding box using a pipe (|) character to separate the coordinates."
Viewport allows you to create a boundary within a specific region, sort of like looking at a larger section of the map within a set of coordinates. Locations coordinates are giving you the exact spot of a location.

Google Maps Static API - Custom zoom with markers

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:

Google Maps API v3 - Zooming to city height after a place search

Is there a way to adjust the zoom Depending on the item searched, say if somebody searched on my application for a city/country/location, the viewport returned will be a bit higher than the city, So all of the city will be Included.
I know if you have several places you can do fitBounds(); but what if it's only one place like a location/country/city
Is there a way of setting the zoom a bit higher than that location?
Google's geocoder API returns the viewport coordinates of the searched object - see the documentation for an example. You can feed the viewport coordinates to the fitBounds method.

Google maps search by address component

I have implemented a basic google places autocomplete in my web app, for example saying "Heraclion, Crete" and it translates it to the latlng coordinates that I want. I also used the mysql radius example from the api to show nearest entries. I also have locations in a second area of Crete, called "Rethymnon".
The problem now is the following. Supposedly one types just Crete. How can I get all the entries from Heraclion and Rethymnon? My code uses the radius approach as mentioned before. So I need something else to define it in a rectangular area.
Is this possible?
If the result contains a viewport (LatLngBounds), you could use that.
PlaceResult
geometry: The Place's geometry-related information. This includes:
location provides the latitude and longitude of the Place.
viewport defines the preferred viewport on the map when viewing this Place