Is there a Geo API that I can query with an area name and receive back a polygon that represents the given area boundary?
Some form of a gazetteer that gives back a polygon instead of the latitude/longitude coordinates.
For example, if I search for "Santa Barbara" I would like to get back the array of the coordinates of the polygon seen on the picture below.
At the moment there is no such function in the public Google APIs. If you search for Santa Barbara using geocoding you will get the location with the viewport and bounding box. However you won't get a polygon around the area. When searching for Santa Barbara using Google Maps it uses a private API to show the polygon around the searched region.
One workaround would be to create your own polygons and save them to your database and then check if the lat/long is within those polygons.
Related
Is there a function in google map that can get the geofence or the polygon area of city? For example i like to get the geofence Manila Philippines. I want to save the polygon Latitude and longitude of the city to MySql geometry column.
At the moment there is no such function. If you search for Manila, Philippines using geocoding you will get the location with the viewport and bounding box. However you won't get a polygon around the area.
One workaround would be to create your own polygons and save them to your database and then check if the lat/long is within those polygons.
I am building a web service with GeoDjango which involves user submitted events including a location. I created a model field for my location using django.contrib.gis.db:
location = models.PointField(srid=900913)
I chose to specify 900913 as I read that this is the projection used by Google Maps and I am getting the location by placing a marker on a Google map. The coordinate is presented to me in lat/lng form. I am storing this point in a PostGIS DB using GEOS:
location = geos.Point(data['lng'], data['lat'], srid=900913)
If I want to view this point on a map, I get the lat and lng from my DB (e.g. lat = location.coords[1]) and use them to centre my map and this works fine.
When I want to browse a map and display events from DB which lie inside the map bounds I use GeoDjango's within query and the maps bounds (in lat/lng format):
bounds = geos.Polygon.from_bbox((swLng, swLat, neLng, neLat))
events = Event.objects.filter(location__within=bounds)
This appears to work fine and I display pins on the map corresponding to the lat/lng of these events.
So far nothing would suggest that anything is going wrong, however I am completely new to this stuff and I want to ensure that I'm getting it right for when I inevitably want to use my location data in more complex ways. The reason I'm suspicious is that my Django admin pane does not display the location correctly on the OpenStreetMap. It shows a point which appears to correspond to the (0,0) point shown here. The displayed text version of the location field is SRID=900913;POINT(-1.277482509613037 50.874104373286066), which is clearly still in lat/lng. As I move my mouse around the admin map I can see the displayed coords in the bottom right corner are in 900913 format, and not in lat/lng.
Please can you explain how I can store my location points in the correct format, and what advantages this has over simply using lat/lng (my guess is that if I want to specify say a distance in km for lookups, I can't use my lat/lng locations).
I would like to move between two addresses in Google maps however i do not have the Geo coordinate latlng (latlng range) for this movement. I can select two addresses from a list which i can make the marker move between. Basically i want to show movement between two locations.
Is it possible that i can ask Google maps for a list of all location names on its map?
Like in this example but i would like to provide a drop down list of all existing addresses in that country
The answer to your question as formulated is no. You can't use Google Maps for a list of all location names on its map, that is against the terms of use. You can get lists like that from Open Street Maps and/or geonames.org (an in the US from the census tiger data), it just might not be consistent with the map displayed by Google.
This is the scenario...
I have a set of lat/long data stored in a db table[id, lat, long, location]. I'm using geo-location to get a user's current physical location(lat and long). When this user accesses the app, allows his location to be shared, I want to get those coordinates that are around his current coordinates, and plot them on a Google Map.
How can this be done?
Example: I have the coordinates for hotels in a city stored in my DB table. When a user visits this city and accesses my app, I want to get from my DB and plot on map only those coordinates that are around him in a certain radius.
Note: I'm using PHP for server side stuff.
Any help is appreciated!
You describe a store locator: finding POIs within a radius around a particular point. A store locator finds POIs within a radius around a location. The details in Google's example are different (you find the centre point via browser geolocation and have a fairly small radius) but the principle is exactly the same.
Google's article: developers.google.com/maps/articles/phpsqlajax_v3
We have a database of addresses that we deliver to. It consists of the following data;
StreetName
NumberFrom
NumberTo
ZipcodeId (points to seperate table with zipcodes, which holds cityName)
StoreId
Would it be possible to highlight all those addrresses on a map like GoogleMaps (preferred), Bing, OpenStreetMap, etc. ?
I know how to add polylines, and have done geocoding in the past for addresses.
A possible issue with the data, is where it covers whole street they practise have been to just set the NumberTo to 9999. If i plot an address into google Earth with 'StreetName 999, City' it will place the point in the middle of the length of the street.
Also tried a random number, and it placed the marker on a building instead of on the street.
I don't know if it's different for GoogleMaps..
Update
I think that the DirectionsService in GoogleMaps API is the way to go, now i only need to figure out if and how i can use it multiple times on a map.
Success!
I was able to iterate over all the addresses, doing a DirectionsService request for each addres, from start of street to end of street. Extract the GeoPoints used by DirectionsDisplay, stored it to the database and is now able to draw Polylines on a map for each road.
I could iterate over the addresseseach time the map is shown (in-house use only). But still this would be a performance issue, and also unsure if how many request Google will handle per day. By storing it in DB i only need Google to calculate it once.
It can, but only in certain areas of the world - e.g. US
But you need to prepare your adresses - lets say in div/spans - then on onload document, you calll the API
I did this using Lat/Lng from a Garmin Edge - the difference is that you need to translate your addresses into lat/lng, before you can position these on the map canvas.
Mike
Yes you can convert the Address to a GeoPoint and then plot the GeoPoints on the Map. Start by looking here