Drawing districts of large cities using google maps or openstreetmaps APIs - google-maps

Is it feasible to build a map using the google maps API or Openstreetmaps which has a superimposed layer that displays districts of a city? For example, Manhattan is a region within New York City, and I would like to be able to plot the boundaries of this region, and any neighboring regions on a map.
Where would one obtain the data for these regions (worldwide)?

I guess this can be achieved by using overpass turbo (which in turn uses the Overpass API) and the MapCSS styling feature by querying for all boundary=administrative relations with a certain admin_level=* tag (6 is for US counties). Although I'm not quite sure if the random colorization is actually possible.
Take this example as a start and see if you can improve it.

Is it feasible to build a map using the google maps API or Openstreetmaps which has a superimposed layer that displays districts of a city?
It is possible. Feasible is up to you.
I generated this map at OpenStreetMap.org.
Where would one obtain the data for these regions (worldwide)?
Photoshop would be one place to start.

Related

Geolocation: How to get a uniqueID for a street/block?

Background I'm a bit new to google maps/mapping sdks in general. I want to create a street by street "heat" map of an area on iOS. As an easy to understand example, let's say it will be for the purpose of mapping daily puppy sightings in a city. The data changes regularly, we need to show that certain streets have more puppy traffic than others.
Similar to the ones pictured here
https://blog.mapbox.com/spotangels-mobile-parking-maps-30db4b10aee7
And here
https://www.trulia.com/local/san-francisco-ca/type:traffic_volume_live
To do this, I would like to get a unique ID for each street block.
Something like this:
Question: How can I tell when a user entered a unique street? How can I get a unique street ID?
Related side question: If it's not possible in google maps, links to doing it in OpenStreetMap or Mapbox would be appreciated.
Places I've looked
How to get an use an unique identifier for each street in google maps api
Issue: No answer
Highlighting whole street with some maps API
Issue: Info from 2010
Google Maps: Get coordinates of a street block
Issue: No answer
Get street graph for a game using Google Maps API
Issue: Info from 2012
Map Highlight Odd/Even Side of Street
Issue: Unanswered
Display traffic data with maps
Issue: Unanswered
How to get only street/road coordinates via reverse geocoding (Google Maps API)
Streets in a radius
How to get all roads around a given location in OpenStreetMap?
Partial solution OSM
This should be doable with OSM data.
Retrieve the streets around you (e.g. using Overpass API and the around query). Determine the way you are currently driving on, then split it at each intersection node. Now you have street segments similar to your second image. The start and end node ID of each segment could be used as (temporary¹) identifier.
¹ temporary, because IDs in OSM can change eventually.

Open Street Maps or Google API for extracting all house locations in a City?

I am working on mapping a city like represented in the real world. So how do I map the exact locations of houses and other key buildings ?. Should I work with reverse Geocoding provided by Google or extract and manipulate raw information from OSM.
You can't to that with the google maps geocoding API, without violating the terms of use, ragarding to chapter 10.5 Intellectual Property Restrictions, paragraph (c) and (e). This solution is very accurate but sadly there is no way to use it outside a google maps app.
The second way is to do it with OpenStreetMap. But be carefull ! OSM is a volunteered geographic map/database, with no guarantee for complete data. In a famous city there will be no problem! But if you want to get the houses in a little hamalayan village you will find no houses/data. But the simplest approach to get OSM data you may take use of the overpass API. You also can use the overpass API via the userinterface overpass turbo. Overpass turbo should be the approach of your choice, because there you are able to beck for existing houses/data parallel on a map.
With this snippet you get all buildings inside a polygon:
way(poly:"50.7 7.1 50.7 7.2 50.75 7.15")["building"];
(._;>;);
out body;

How to request polygons from Google Maps?

I am interested in an analogue of http://wiki.openstreetmap.org/wiki/Nominatim
I.e. to be able to make request and get some kind of polygon coordinates:
"geojson":{"type":"Polygon","coordinates":[[[-87.464761,44.600998],[-87.459755,44.599569],[-87.459745,44.601012],[-87.463143,44.601],[-87.464761,44.600998]]]}
Nominatim is good, but it lacks of some data (I am interested in data about cities and counties of Canada). For example, Google Map knows about the Ontario districts and highlights them, but OpenStreetMap - does not. As well as for some cities - where OpenStreetMap shows a dot, Google Maps shows full polygon.
Can it be done with Google Maps?
Other alternatives will work as well.
Yes, it can be done via GMaps API: https://gis.stackexchange.com/questions/43292/how-to-geocode-an-address-to-a-polygon
But be also aware of the legal restriction of the API and the commercial dataset, esp. if you want to use it regularly or for bulk processing: http://www.google.com/help/legalnotices_maps.html
I would also consider to help OSM to improve the dataset. This can be done by contacting the local community and offering help to ask for official public datasources. Esp. in the case of political boundaries, there is no way to get this material on the ground: http://wiki.openstreetmap.org/wiki/Canada

Google Maps API draw; city, country, county, zip, state

I am developing a visualization based off google maps. There are a few requirements the most complicated being rendering different areas on a google map. I need to render a few different sets of polygons based on zoom so maybe country, state, zip etc. It seems as if I will need an array of latitudes/longitudes which outline each of these areas. Are there any resources for these?
I see something called fusion tables which allow users to implement kml shapes on the map. However those dont seem to meet my requirements as I will need to add thresholds to each polygon which is rendered.
Lastly would it be a bad idea to render a large number of polygons. Would you expect me to run into issues? Lets say I render all 50 states, would this cause problems?
This will all be done on the fly and rendered programatically. I will be building these polygons to be renderd based on the contents of a report so what I am rendering can change with each execution.
You can download many free shapefiles from the internet, for example # http://www.diva-gis.org/gdata. Maxmind has also a free world geo database. You can download my PHP class concave-hull # phpclasses.org and try to pull a shape from the Maxmind world geo database. You can also try my example # http://www.phpdevpad.de/geofence/. It also gives the concave-hull. Personally I can also recommend Geonames for a zipcode world geo database.
A Very Simply API exists for this query by zipcode,city,etc.. returns geoJson
https://www.mashape.com/vanitysoft/boundaries-io/overview
Image of the results in GooleMap

How to find a closest street

I'm reading through Google Maps API documentation and I wonder if such a think is possible:
I specify the point (by coords)
I search for all roads, and junctions around the node (say in 1km radius)
I get parameters for the streets around (polyline coords)
Is it reachable, or google do not share that data?
Thanks in advance
Rafal
I can image writing up a little script that generates a bunch of random points within a 1km radius and then performs directions services via Google Maps API to obtain all possible routes and thus streets within a 1km radius. However, this is problematic since it is kinda against the Google Maps TOS of displaying this information only on a map within a website and not extracting data for you personal use as this would be.
A better approach would be looking into utilizing Open Street Map data where you can download street data from a specific viewport. If buying street network data is an option, you can go to a commercial outlet such as NAVTEQ or PTV which post-processes NAVTEQ data to a format for use in the transport modeling software package you mention on your blog.