Friday, 1 June 2018

How to get square meter or square km using in html5 / ionic

Here is what I am thinking. I want to get user location using GPS. Instead of sending current position I want to calculate square km or meter.
----------------------------------
|                                |
|                                |
|                                | 
|                                |
|              .                 |
|              ^                 |
|      My current position       |
|                                |
|                                |
|                                |
----------------------------------

As you can see in figure above, my current position but I want to calculate the whole area around that in HTML5 or Ionic would be more preferred.
Update
enter image description here
In above image the red dot is my position and I need to get the whole area in red rectangle. Get that store that in database. I looked into the Polygon area formulas but that requires several vertices, with geolocation I only get longitude and latitude just two coordinates. How am I gonna do that using these two points?
UPDATE
I found a solution here but this solution is keep tracking user's current location and in calculateDistance function the formula uses both current location (longitude and latitude) and tracking location(longitude and latitude) i.e. Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) * Math.sin(dLon/2) * Math.sin(dLon/2);
This works perfectly fine for my second scenario but first I do not want to track user's location at first. First I simple get current user location(longitude and latitude), calculate the area from that and send it to server. Now I am not sure how am I going to achieve that. Any help?


from How to get square meter or square km using in html5 / ionic

No comments:

Post a Comment