Calculating bounding grid coordinates to a user click on google maps/google earth?

Up vote 1 down vote favorite share g+ share fb share tw.

I have a requirement to calculate the centroid or geodesic midpoint of when a user clicks in between the lat/long grid crossing. The crossing forms a square in most parts of GE and sometimes elongated rectangles. This is due to the shape of the earth of course.

I'm looking for a valid mathematical formula that would allow a user to click anywhere in between this grid and then an accurate function (in Javascript or server side code) that would take an assumed grid resolution (say 1km intervals for this discussion) and the input coordinates that should return a centroid coordinate within that graticule grid. To clarify please take a look at the attached image to my google group post:

?gda=h5oFPz8AAAD315KpovipQeBwdfGpmW3ZhBc9PTADwYa-n193hZ6AItFmHuno63c7phcEXYVuRA6ccyFKn-rNKC-d1pM%5FIdV0&gsc=sz6bbAsAAABBKF7YXWYyc4GmXg-QruHj What I need to be able to do is if a user clicks anywhere in this grid square, I need to find the centroid or center point of that grid intersection/square or at least the bounding grid coordinates (that make the square). If we assume that the grid is UTM standard and has a max resolution of 1km (or make this a parameter), I need to detect the four other points nearby and then calculating the centroid is not as difficult.

I welcome any feedback you all may have and appreciate it. I don't have a simple way of letting a user click anywhere on the grid and finding the grid bounding coordinates (making a square of 4 coordinates) or the centroid / midpoint of the graticule grid square necessary. One thought is to use assumptions as much as possible using a reference such as UTM coordinate reference.

If I assume that the grid is X degrees wide, can we have a pure javascript function take any input coordinate and return for me the bounding graticule coordinates in Decimal Degrees? Another thought I had was to create the grid in a geo-spatial layer to take any input coordinate and return the nearest centroid of the graticule? Does this make sense?

Thanks! Omar google-maps gis coordinates google-earth google-earth-plugin link|improve this question asked Sep 8 '09 at 16:59user170304.

The mathematics would be different depending on the projection used. Is something like this what you're trying to implement? : iwa.yangman.

Ca/~yzhao/gis/mgrs. Html – Yang Zhao Oct 31 '09 at 18:49.

This seems to be a rounding problem 1) your users click anywhere on the map 2) you want to trap the click to read out the actualLat/actualLon values 3) and round it down to the nearest discrete grid values minLat/minLon 4) then you want to calculate and return in some way the midpoint of the grid as midLat = minLat + deltaGridLat/2; midLon = minLon + deltaGridLon/2; ad 2) look up the . Js file in my Maidenhead locator viewer - you can surely reuse code for initializing the GE event handler and the handler for a mouse click (note I am trapping a RIGHT click) The event handler essentially takes the user chosen location, passes it to function CoordToLoc() where the coordinates are converted to a Maidenhead locator string, which then is displayed in field inpLocator on the web page. Ad 3) this depends on your grid - if it is bound to discrete Lat/Lon values (as in my case) it's as simple as rounding.

If the grid points are defined as distance offsets in km from a reference point, the simple approach would be to divide your argument by the unity length and disregard the decimal places Hope this helps Good luck MikeD.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions