I'm trying to work out if I can limit the area a user can select on a google map depending on population density in the area.
So for example, a user would be able to select a small area of a map in a high population area, and a large area of the map in a low population area.
The maximum area a person could select (regardless of population density) would be small (~50km to a side) and so I'd work with the average population density for an area.
Does anyone know if such a thing is possible using Googles Map API or would I have to import and query another data set or service?
Related
I'm trying to place a series of overlays onto a Google Map. I'm following along with the sample code for ground overlays, but that only allows me to dictate image placement using north/south/east/west boundaries. The works as long as my image is a rectangle and oriented along longitude and latitude lines. I'd really like to be able to accurately place an image, including custom scale and angular orientation. That doesn't seem possible with a ground overlay.
So here's a possible use case. I'm building a website to help city planners test parking availability.
The city planner uses a Google map on the analysis website to select an area of the street with a polygon select tool.
The website script tests the selected polygon area for parking availability.
When we're done with the evaluation, I'd like the site to paste random images of cars into the page so the user can better visualize what's available.
I can create a rectangular plan view of a car, but I'm unable to figure out how to rotate the image by X degrees as required. Perpendicular to North/South/East/West (NSEW) is no problem, but I'm unable to angle it.
This should work no matter how the original map is oriented. The goal is the user sees a proposed solution, complete in the current map view, and to scale.
Obviously the image would have to be perfectly scaled to the visible map, and that's fairly easy to do (a minor latitude length adjustment may be required.)
(In this image, the city planner has just selected the area of interest via polygon selection tool. The next step is to evaluate the area, and paste in some parked cars, aligned and in scale!)
All the Google mapping native overlay tools I'm looking at rely on LatLngBounds class, hence the NSEW perpendicular alignment problem. I know I can calculate the desired angle, go to a php server, rotate a .png image with transparent background, per php imagerotate, but that seems like such a hack for a geo-mapping exercise. I could also pre-rotate the cars in a .png file and save them as red_car_15degrees.png, blue_car_30degrees.png, white_pickup_45degrees.png, (three different cars x 5 degree increments from 0 to 45 degrees) but that too, just feels like a hack.
Is there anyway to create a custom map overlay at a given desired orientation angle, so I can layer in the cars to show the city planner what's available? Many thanks.
I would draw and rotate in a <canvas> and then out that on.
EDIT:
place on canvas, ctx.rotate, c.toDataUrl(), and overlay that on your map.
I want to create a heat map using Google API (Javascript). The problem is that Heatmaps use colors to represent the density of points. But, in my case the density of points is irrelevant. I want to create a map using a specific set of values. The colors on the map will be determined by that value only for that location. My set of values is Latency (ms).
Example: If a value is low it will appear on the map with green color. If a value is high it will appear with red color.
I´ve searched the API documentation, but the only thing i found was using "weighted locations". This is not a suitable solution, because the density of points is still considered.
I realize there are some conceptual gaps in my knowledge—I'm not 100% clear on how everything fits together in Mapbox. Hopefully someone can set me straight and help me achieve what I'm trying to do.
Our client is a multinational corporation with locations divided into global regions: North America, South America, Europe & Africa, Asia Pacific, etc.
What they want is for the initial map view to be a zoomed-out world map. When each of these individual regions are moused over, the countries belonging to that region will be highlighted, a label will be displayed with the name of the region, and clicking will zoom the viewport to center/display the region.
The problem is that there is no concept of a region in the map, and I'm not sure how to add one programatically.
The underlying country map was created and styled by a designer using TileMill. It uses the Natural Earth country map. When I look at the project in TileMill and inspect the layer "features", it appears that the shapefile has a list of the individual countries with some associated metadata. So far so good.
Ideally, on the client side, I would have a list of countries belonging to each region. When the user mouses over an individual country, I'll figure out what region it belongs to, iterate through the country list and apply an effect (like opacity) to highlight the region.
The problem is, I can't figure out how to get the country metadata in the TileMill file for whatever country is currently being moused over. Is it even possible to attach events and access the features added in TileMill?
FYI: an alternate approach I tried was adding this map data at runtime. I was able to attach events to GeoJSON features, but the granularity of the map is WAY lower than the underlying map, so it doesn't line up correctly at higher zoom levels.
The problem is that there is no concept of a region in the map, and I'm not sure how to add one programatically.
Okay, so the fundamental thing to understand here is the difference between interactivity you add in TileMill and interactivity via GeoJSON, in Mapbox.js.
TileMill supports raster interactivity based on UTFGrid, and exports tiles. It can handle high levels of detail and thousands of features, but since the geo data itself is not transferred to your browser, you can't do hover interactions like highlighting data - you can only open tooltips and popups
Mapbox.js/Leaflet support vector interactivity. They can handle much lower levels of detail and amounts of data. But the geo data is transferred to your browser, so you can do hover interactions as well as adding tooltips.
My requirement is to save the specific are from the GMap. For example, I want to save the location are of NewYork city and once any vehicle entered in this area then we will get an alert. Vehicle updating his information through GPS.
Please suggest me if anyone having some experience about it.
I'm not sure what you mean exactly by "save the specific are from the GMap".
If you mean that you'd like to save a 'viewport' then you could retrieve the viewport coordinates for a particular search and use that as a defined area. Viewports are just large squares though, so this will include areas that are not 'New York City'
If you want to be more precise - i.e. to flag a car as it enters Manhattan, you would need a more detailed KMZ for the Manhattan New York City area.
The New York City Department of City Planning (DCP) provide KMZ's of all the boroughs which could be used to achieve a more accurate view of the area of interest. You could stitch them together to create an 'official' NYC city limits polygon.
https://www.google.com/fusiontables/DataSource?dsrcid=1767628
To determine if a vehicle has entered any of these areas you would need to perform a 'Point-in-Polygon' test against the KML polygon(s).
There are previous discussions on how to do that Here and Here
Hope that helps
I need to divide USA map into political boundaries. i.e. states and in seven Regional boundaries on Google map. Each region will have its own color. Example, California, Hawaii, Nevada, Utah, Arizona and Colorado (Southwestern US) will all be same color. Political boundaries will also be on map along with regional boundaries. On national view only regional names should be visible and no state name. On zooming in to region state names will be shown, no city name should be visible either I zoom in or out.
Can you please help me understanding that from where should I start? Links? Tutorial?
Do I need an Image to put on map as overlay.
I am really not getting it.
If you want to close this question then please help me that what is the forum to ask this so I put it there?
I need to divide USA map into political boundaries. i.e. states and in seven Regional boundaries on Google map. Each region will have its own color.
You can do this with a relatively simple polygon overlay. You'll need to obtain polygon data for each region of interest from a third party since the API does not provide any.
On zooming in to region state names will be shown, no city name should be visible either I zoom in or out.
This starts to get more complicated. Probably best done using a custom map type (see image map types) if you don't want to see features like city names.
See also
Google Maps w/ counties overlay?
http://maps.forum.nu
State polygon overlay example (for API v2)
MapTiler - Map Tile Cutter
Polymaps - a personal favorite alternative to Google Maps, with a really slick API