I'm trying to detect the coordinates of some markers based on current location, but my problem is, sometimes, the accuracy range circle of my current position is relatively large and i have very difficulty to detect those markers because my current location is a little far from the markers. My question is if there is someway to check if the coordinates of those markers are inside the accuracy circle of my current position, or to get the radius distance of the circle?
Accuracy parameter is precisely the radius of a confidence circle. From Android doc:
We define accuracy as the radius of 68% confidence. In other words, if
you draw a circle centered at this location's latitude and longitude,
and with a radius equal to the accuracy, then there is a 68%
probability that the true location is inside the circle.
You can also get distance between two GoogleMap Point doing this:
Location location1 = new Location(point1.latitude, point1.longitude);
Location location2 = new Location(point2.latitude, point2.longitude);
float distanceInMeters = location1.distanceTo(location2);
Related
I am trying to Understand that What happens to the Latitude longitude when moving to North or south or east or West.
Suppose My current GPS coordinates are;
Latitude = 33.659832 Longitude = 72.345678
Now what will be New Latitude/Longitude 30 METERS to the North of my position also tell me towards south, east and west direction.
Please be specific thanks
Latitude is related to South -> North
If you move North, the latitude increases, if moving south it decreases.
Longitude is related to West -> East
If you move East, the longitude increases until 180 and when you cross that datum limit it jumps to -180.
If you want to calculate a new coordinate by offset meters and direction,
you find code here at stackoverflow.
To play with coordinates you can use http://www.geomidpoint.com/destination/
where you enter the coordinate and the offset in km, and the compass direction in degrees.
The calculation is done either using
complex spherical formulas for calculation of big distances > 1km - 10km or
using school mathematics (Polar coordinates (r, phi) once you have
converted the lat, lon to cartesian space, e.g using a
equirectangular projection. That is suitable only for smaller distances less than about 10km
I have been searching but I couldn't find it. I am using google map v2. Is there any way I can convert distance ( meters) to pixels on my screen? I need the pixels equivalent of the distance. I have the distance and I have the zoom level.
Any help is appreciated.
If I understand correctly, you have a MapFragment on your screen showing a map. You know the distance in meters between 2 points on the map that are shown on the screen and you want to calculate the distance between those two points in pixels. If you know the LatLng location of the two points, you can use the Projection class like this:
Point point1 = map.getProjection().toScreenLocation(latLng1);
Point point2 = map.getProjection().toScreenLocation(latLng2);
and then you just need to use the distance mathematic formula:
I have a marker in my Google Maps map that looks like this:
When the user is driving, I want to rotate it based on his driving direction. How can I achieve this? I should probably use previous location and current location coords for calculation, but I have no idea how.
If you use GPS for locating the user then the Location object you get in onLocationChanged contains the bearing.
If you only have the two coordinates (e.g. you only have coordinates from network location provider), you can use Location.bearingTo() to calculate the bearing of two coordinates:
Location prevLoc = ... ;
Location newLoc = ... ;
float bearing = prevLoc.bearingTo(newLoc) ;
If you have a bearing, you can set the rotation of the marker using MarkerOptions.rotation():
mMap.addMarker(new MarkerOptions()
.position(markerLatLng)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_marker))
.anchor(0.5f, 0.5f)
.rotation(bearing)
.flat(true));
You have to set the anchor to the point you want to rotate around, and it's also the point you want to be at the position you set to the marker. (0.5, 0.5) is the center of the image.
I have a little problem using Android.
I have my GPS position, clearly latitude and longitude, and a ray of search in meters (for example 100 meters), ok?
Imagin my position at center of the circle made by ray, I would know how to obtain on Android the:
topLeft Latitude
topLeft Longitude
bottomLeft Latitude
bottomLeft Longitude
of the rectangle that inscribes the circle.
Thank's in advance.
1) Convert center lat long to cartesisan x,y in meters:
(lat lon are on a sphere, x,y is a flat map then you can continue with school mathematics
2) use polar coordinates formula to create the 4 corner points
the first corner has angle 45 degrees, and r = 100m
second corner of the square has angle 45 + 90 degrees
3) convert back the 4 cartesian meter coordinates to lat,lon
a bit more detailed here
How to find a set of lat/long pairs surrounding a 5 miles radius of a certain location
and see my answer here
PHP: How to create a Geo-Fence(bounding Box) using the Distance from a set of Coords
In Android, if I have a circle's radius and center value, how could I measure the latitude and longitude of about 1 km periphery of that circle?
Horizontal = x-axis = Longitude
Vertical = y-axis = Latitude
Latitude and longitude are terms necessary to define a position on a sphere, where two angles are necessary. These terms have no relevance to a circle, which exists only in one plane.
This is not an easy problem to solve as the distance between each latitude and longitude varies depending upon where on the globe you are (I'm sure some maths boffin could do it, but it is beyond me). For instance at the north and south pole one degree longitude measures no distance at all, but at the equator one degree can be several kilometers. If however your search only relates to a small are of the globe, then a you can make a reasonable approximation by using 1km = x degrees where x is the correct value where you are.
Terms "circle", "radius" implies a 2D flat plane geometry whereas "latitude", "longitude" implies a geographical coordinates on a 3D ellipsoid.
Putting these problems asides, let's assume, in fact that your "circle" is a point on the surface of our Earth and, the "radius" is a distance from this point. This will correct your terms so they define a 3D problem.
If a projection is given. Then we can specify the "center" in planar geometry coordinates (X, Y). We can specify all points distance "R" in geometry coordinates as (X + R * cos(phi), Y + r * sin(phi)) then we can use the projection to convert the geometry coordinates from planar to geographic i.e. longitude, latitude. The problem is 1000s of projections exists and not all a valid across the entire Earth.
Alternatively, you can define your 3D ellipsoid in 3D space using (X, Y, Z) coordinates. Then the wording of your problem must change. The "circle" because a sphere whose point is on the surface of the ellipsoid and the "radius" is the radius of the sphere. To compute all points distance "R" from the sphere you will need to intersect the sphere with the ellipsoid using trigonometry. After you have done this, you can convert the resultant 3D coordinates back to longitude, latitude based on the definition of your ellipsoid.