How to know how many mils are currently google map is showing - asp.net

i have got center of map using map.getCenter(); and i got current zoom of google map using getZoom(); please tell me how can i calculate/get current show mils area in google map. i am using asp.net and javascript.

With GMap2.getBounds() you can get the visible rectangular region of the map view.
Then using these coordinates you can construct a GPolygon object and calculate the area in square meters using GPolygon.getArea() function. Then convert given area to mils (1 meter = 39 370.0787 mils).

the GLatLng object has a distanceFrom function that takes another GLatLng. The map has getBounds from which you'll be able to get the corners of interest, and check the distance between them.

Related

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

How to measure geometry efficiently in Google Map

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.

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.

optimal zoom distance to show all polyLines at map load

I have a map with multiple polyLines.
I want a function that I can send a group of polylines to, and it return the tightest possible zoom range to show the lines entirely.
Add all the points you want visible to an empty google.maps.LatLngBounds object (with .extend()) then run .fitBounds() on the resulting bounds.
All the points you want visible are all the vertices of all the polylines.

Selecting Map Points Inside a Map Poly

I'm trying to find an algorithmic way to select which points fall within a specific arbitrarily shaped area on a Google Map. Basically I want to be able to provide a point and ask a function if that point lies within an arbitrary (but specifically defined) map area.
For example, how could I tell if a point was contained within the green section (Brions Regional Park) on the follow map:
http://maps.google.com/maps?ie=UTF8&q=state+park&fb=1&gl=us&ei=Rm-tTIGRBI2jnQeXrZyTBg&ved=0CEoQtgMwAw&sll=37.912242,-122.078705&sspn=0.086,0.17355&split=1&rq=1&ev=zi&radius=5.68&hq=state+park&hnear=&ll=37.934585,-122.13192&spn=0.089358,0.17355&z=13
I need help figuring out how to define the specific area and also then the algorithm that would take in the defined area & point and return true/false.
Thanks in advance for your help!
This has been helpful for me:
https://github.com/tparkin/Google-Maps-Point-in-Polygon

Resources