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.
Related
I am having an issue where some coordinates are providing correct streetview image while others are off by several lots. For example, the coordinates for 42.4025192834409,-83.1636018491871 in streetview bring me to the intersection nearby. If I enter those coordinates into google maps the pin location is correct but then I can't drag the streetview icon in that section. Is there anything we can do differently with our coordinates so that they go to correct location for streetview?
When I search for the address it works as you are seeking. I think this is the discrepancy you are experiencing:
https://developers.google.com/maps/documentation/streetview/intro
The Google Street View Image API will snap to the panorama photographed closest to this location. When an address text string is provided, the API may use a different camera location to better display the specified location. When a lat/lng is provided, the API searches a 50 meter radius for a photograph closest to this location.
You may want to try reverse geocoding.
Try again now.
https://maps.googleapis.com/maps/api/streetview?size=640x480&location=42.4025192834409,-83.16360184918&fov=90
When I read your question two days ago, it was actually getting the wrong panorama. I tried again today and it finally got the closest panorama to those coordinates. I guess it was an issue on Google's end.
I have to find out whether a given lat/long value is with in a circle/rectangular area whose centre is some lat/long with some fixed radius.
is there any google maps API available for that ?
You can look at the documentation - containsLocation
Here is the link:
https://developers.google.com/maps/documentation/javascript/examples/poly-containsLocation
I am using google maps API to get coordinates from a typed location. What I was also hoping to do was get the radius of the place, possibly using "bounds".
For example, if I geocode "England" it gives me a coordinate, but it doesnt tell me it's radius is very large. Whereas if I geocode "London" it again gives me a coordinate but doesnt tell me that it's radius is much smaller.
So my question is, is it possible to get an estimate of the size of the area being geocoded from the google API as well as it's center coordinate point?
Thanks!
You should be able to get the bounds via the GeocoderResult's geometry.bounds or geometry.viewport properties.
https://developers.google.com/maps/documentation/javascript/reference#GeocoderGeometry
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
I'm developing a mobile application on phonegap.
For the Geolocation I'm using Leaflet "a JavaScript library for mobile-friendly maps"
and I just want to know if it is possible to display the map per country without having access to the others. So the user can just navigate in his country.
Leaflet allows you to set limits on zooming and panning.
One solution would be to just limit the viewable area of the map to the coordinates needed for certain countries.
I am quite sure that there is geodata available out there giving you the highest/lowest latitude and longitude values per country (sort of a bounding box around a countries borders), so you could just limit the viewable area to those values.
To limit the viewable area use
Map.maxBounds(..LatLngBounds..)
More here http://leafletjs.com/reference.html
According to this bug in the GitHub issue tracker for Leaflet, it seems that this is not possible at the moment.