Google Maps API draw; city, country, county, zip, state - google-maps

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

Related

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

Drawing districts of large cities using google maps or openstreetmaps APIs

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.

Given list of countries draw map with those countries a different color

Looking to the do what the title says - produce a world map image that colors particular countries. I'm open to platform - Processing or Python/Basemap preferable. Web based service ok if it has an API.
Anyone have direction on this?
have you looked at GIS? There are a number of open source and free clients that allow you to work with various maps (probably .dwg) with various corresponding data in xml format to produce geographical visualizations through queries and you can export a number of formats. I think this would give you either the visualization that you want or the data to plug into processing or whatever to create it.
Get the map data in shapefile format, look at python bindings to OGR and GDAL, or maybe try Fiona: http://sgillies.net/blog/1095/fiona/ or SciPy, or just download Qgis www.qgis.org and learn some GIS skills.
Country-level shapefiles for the world are fairly widely available www.gadm.org maybe.
Google Geomap did the trick here.
It's part of their chart visualizations tools. A javascript call that returns an SVG map colored according to data that you provide.

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.

Can I show a single country (masked out) in GoogleMaps?

Is it possible to mask away neighbor countries in GoogleMap? In my case I just want to show Sweden on one view. On a second view just Norway, Denmark etc etc...
I know it is possible to draw polygon lines and fill them accordingly on to Maps API. Problem is that or the result sets get huge or the lines get very rough etc... Would be nice if GoogleMaps could deliver a country at the time without neighbors.
Does anyone know about a good coordinate database with country borders?
You can create very complex polygons in Maps without a drop in performance if you store them in KML file format and load them as KmlLayers. KML is an XML based vector file format for geo data. The beauty of using KML files in Google Maps is that they are rendered on Google servers into simple PNG files, matching the current resolution and bounding box of your Maps view at any time, no matter how complex the original polygon data is. So all complexity is handled server side at Google.
Here is a sample of a project, where I have used such a masking for one of the federal states of Germany. (The surroundings in this case are not fully masked away but only dimmed. But you can also mask them off just as easily by changing the alpha value of the fill color in the KML file.)
For a quick review KML files can also be loaded directly into the Google Maps public website (by entering their URL into the search field). Here is the KML file that I have used in the above project, loaded directly into Google Maps. (I have actually used a KMZ file here, but that is simply a KML file packed into a ZIP archive. You can pack and unpack it with normal ZIP tools.) BEGIN UPDATE 07/2015: Unfortunately Google has REMOVED the possibility to directly enter the URL of a KML/KMZ file into the search field of their public Google Maps when they launched its redesigned version in 2014. You can still use all techniques discussed in this answer but you cannot simply preview KML files by entering their URL in the search field anymore. If you need the KMZ mentioned above for further analysis, you can download it here. END UPDATE
Please be aware that Google implies a size limit to KML/KMZ files (currently 10 Mb uncompressed, 3 Mb compressed - details see here). If your KML files should be to large, there is software available to reduce the complexity (see examples here and here).
You will find free map data at many places on the Internet, most of them being in ESRI shapefile format. A great source for country maps is http://www.gadm.org/ with the big advantage of providing their data in KML/KMZ format too. If you should have to convert ESRI shapefiles to KML, have a look at the great (and free) OGR converter.
Please notice that KML files are only a solution if your polygons are static (like the border of Sweden is) and not depending on any user input. For dynamic polygons you will still have to use the Polygon class of the Maps API with the complexity restrictions that you have mentioned.
had a similar problem and managed it by combining gamps with fusion tables:
var table_id = 420419; //can be exchanged wit another table
var FT_Query = "SELECT 'kml_4326' FROM "+ table_id +" WHERE 'name_0' NOT EQUAL TO 'SWEDEN'";
var FT_Options =
{
suppressInfoWindows: true,
query: FT_Query
};
var layer = new google.maps.FusionTablesLayer(table_id, FT_Options);
layer.setMap(map);
Have you considered loading in a custom map?
I haven't used it myself, but hopefully that link could help you out a bit :)