How to measure geometry efficiently in Google Map - google-maps-api-3

I would like to add color to each house in the following google map example:
https://www.google.com/maps/#43.0748326,141.3479359,19z?hl=en
I found an example in leaflet that add colors to US states by giving the GeoJson data including the corners coordinates of each state. You can find the example here:
http://leafletjs.com/examples/choropleth.html
I would like to do it with Google Map. Two questions in front of me are:
1. How can I get the corner coordinates of houses?
2. As the number of houses which I want to add color is relatively large, how can I efficiently measure the corner coordinates of these houses?

How can I get the corner coordinates of houses?
You can't. The data in Google Maps API is not available to you, because of technical and legal restrictions.
You'll likely want to do this some other way: for instance, with OpenStreetMap data and one of the many services that visualizes it.

Related

Determine minimum number of "invisible squares" to cover all markers on a map?

I have a map full of markers corresponding to GPS coordinates, represented as a PostgreSQL + PostGIS database table using "geography" type for the GPS column.
Imagine, if you will, one semi-transparent square on top of each of these points corresponding to 1x1 mile, based from the centre, often intersecting with each other.
I'm trying to determine the minimum number of such "squares" and their GPS coordinates, so that they "cover" all of the markers with a minimum of 25 meters to the nearest border.
If it makes it any easier, the positions of these "squares" don't have to match the positions of any of the markers.
The purpose of this is to attempt to cut down the number of API requests to a "houses for sale" service significantly, since most of the positions are close to each other and the API takes a 1x1 mile square "bounding box" as the input for each call. It would be insanely wasteful to call the API many times for basically the same area when maybe 1 or 2 times would do it if I can first figure out where these imaginary "squares" go.
I get the feeling that this is considered a "known, common and solved" problem, but so far, I've not been able to figure out how to do it.
Sorry, but it seems like you have no idea what you are doing and are just being rude, both here and at PostGIS irc-channel.
You give no information about your api.
What is creating your maps?
Is it a wms-service or what?
What most people would do is setting up a mapservice with a tile cache. Then the mapservice will pich the tiles needed for each house you want to show ( or multiple houses).
The tiles will be prepared o will be created on the fly. But they will be cached for next time.
So, I think you should read up on things like
MapServer
Mapnik
MapCache
Mapproxy
GeoServer
That is not a complete list, but might give you some ideas about what it is that you want

how to know in which region is the markers using leaflet map

I want to the count of markers based on location using leaflet map
ie,
Say in india
Number of markers in bangalore
number of makers in mysore so on...
only thing i would think of to do this is using contains( point )
which is in the doc
But how to use it to find the maker is in that region as i will not be aware of the coordinates of the region
Is there a way to check like
region.contains(markerLatLang)
Leaflet .contains() works on L.LatLngBounds objects, which are actually a rectangular region. So it tells if your point / marker is within a rectangle or not.
You would need first to retrieve yourself the coordinates of your administrative areas of interest (India, etc.). See https://gis.stackexchange.com/questions/199765/where-to-get-world-wide-detailed-administrative-boundaries
BTW, a simple version of countries boundaries can be: https://github.com/johan/world.geo.json
Then you would probably want to use a more accurate detection method, for example leaflet-pip plugin or turf.js, which will actually check if your point is within arbitrarily shaped polygons, not just a rectangle.
See for instance Leaflet event: how to propagate to overlapping layers

Grid based Clustering

I am trying to do a grid based clustering, specifically where each U.S. state is a grid. What I am doing now is just setting strategy option of ClusterProvider to STRATEGY_GRID_BASED, but I don't think this is what I think it is.
I tried looking into nokia.maps.clustering.IGridOptions, but there isn't anything documentation on that.
Can someone point me in the right direction? Thanks.
A Grid-based clustering strategy just breaks the map up into squares and calculates how many markers are found in each square. What you are after is known as a Chloropleth Map. The most efficient way to do this would be to cluster server-side, return a key,value pair (i.e. state, number of markers) and just display polygons for the US States. An example of such a map can be found in the HERE Maps community examples which displays the accession dates of states to the union.
If you insist on doing everything client side then you'd have to use the following pseudo code instead:
Iterate though each marker in your list:
Check to see if it is within the hit area of an existing polygon.
If it is - increment the markers counter (an additional attribute you have added.)
If it isn't make a WKT State-level shape geocoding request, and parse the result -add a new markers counter attribute to the Polygon
repeat
You will then end up with a series of polygon objects each holding an attribute with the number of markers within found within the state.

Can I force Google Maps to draw polygons with overlapping paths as a union rather than intersection?

I'm working on a custom Google Map where I need to have place marks made up of several polygons. When I was using a KML file, the polygons would union together, however I had to abandon KML due to the need to present the infowindow programmatically from other items on the page.
Now that I'm drawing polygons directly (new google.maps.Polygon) I find that sometimes the items are joined via union and somethings via intersect. This appears to be related to how much overlap there is.
My polygons are building shapes with their corresponding labels so I've wanted to keep the two as separate paths if possible (though this isn't necessary).
Is it possible I'm missing a setting that tells the engine how to join the paths? PolygonOptions shows nothing, but perhaps there's a hidden feature to do this.
If you have multiple paths in a polygon, the regions will subtract if the winding direction is opposite (the relative order of coordinates i.e clockwise or counter-clockwise).
Some examples:
http://www.geocodezip.com/v3_polygon_example_donut.html
http://www.geocodezip.com/v3_polygon_example_donutA.html
http://www.geocodezip.com/v3_polygon_example_donutB.html
http://www.geocodezip.com/v3_polygon_example_donutC.html
similar question

Divide a city into regions in Google Maps

I am trying to divide a certain city into several blocks, each representing North, North-West, North-East, South...and so on. I just need the coordinates of the region boundaries (e.g.: North is between X and Y latitude and between Z and T longitude), so that I can check in my app whether a point belongs to a region or another. The regions should not depend on a certain zoom level's boundaries and they don't need to be the same size (maybe the North part of a city is a little bit larger then the South one).
Any idea how can I "draw" these region boundaries? Thank you!
For boundary data, you would have to do a search. Depends on the city and country. In the US, many municipalities provide this data directly through a city or country web site. Generally it will be in a GIS data format such as a shapefile. You have a number of different options for working programmatically with GIS data formats. I recommend using the GDAL libraries,
particularly ogr2ogr. Once you've got the boundary data, you can draw it on the map using polyline overlays or create a raster images of the data, say using gdal_rasterize. Or you can convert the data to KML using ogr2ogr, and upload it to Google Fusion Tables using Google Docs and overlay it using a FusionTablesLayer.

Resources