Android Google Map filled circle - android

I am trying to make a map overlay that just shows a solid circle from the map center who's radius is a range in meters.
I can't figure out how to calculate the circle's radius. I can get the map center, but I haven't had any luck figuring out how to convert meters into the proper units for the circle's radius.
Thanks for any help.

I've got no experience of doing this in a gMaps context, but the MapView class (whose getProjection() I'm assuming you've used to work out where your point is on the screen) has getLatitudeSpan() and getLongitudeSpan() which you can use against the screen res to calculate the pixel-radius of your circle.

Related

How can I draw real-sized marker of Bitmap on Android Google Maps?

I have a map application and cluster of markers. Marker icons are created with BitmapDescriptor.createBitmap. Icons are simple - dot in the center and Gradient circle around it (But this gradient circle should have real-sized radius, meaning if data is 30 meters for the radius - circle should be 30 meters in radius for any zoom level anytime on the map). How can I achieve this, as radiuses in createBitmap argument seem to be dp dependent? I am using ClusterRenderer's onClusterItemUpdated to render a new marker for each zoom level, but can't set a real radius to a bitmap.

Calculate the area of the shown map

Given a MapFragment with any zoom level at any time, is it possible to detect the area covered by the map?
For instace, I'm at Lat: 38.766667 and Lon: -9.15 with the zoom level at 15.0f, how do I calculate the area covered or how do I obtain the top left corner and bottom right coordinates?
you can get the corners of the view area by doing:
googleMap.getProjection().getVisibleRegion().
//farLeft;
//farRight;
//nearLeft;
//nearRight;
//or
//latLngBounds;
Keep in mind that if you have tilting/inclined view the real view area is not a rectangle but a trapezoid.
Have a look at the documentation here to check what is best for you, latLngBounds gives the "smallest" rectangle, that is not the exact area!
https://developers.google.com/android/reference/com/google/android/gms/maps/model/VisibleRegion

Area Circle Overlay

How do I draw a area circle overlay underneath a marker?
For instance you would give the area circle an origin coordinate (Latitude, Longitude) and a radius relative to the origin.
So when you zoom in and out of the map the circle will scale with the zoom level correctly.
There is no standard Overlay in osmdroid for that, but it's quite easy to implement that by copying and simplifying this one: DirectedLocationOverlay

Google MapView zoomout to span a circle

I have a MapView centered at point P. The user can't change the MapView center, but he can choose a radius of a circle to be display around point P, and change it dynamically with the map being redrawn at each change to show the new circle.
The thing is, i want the map to zoom in or out as necessary, in order to display the entire circle at the viewable area. I've tried this:
Projection proj = m_Map.getProjection();
Point mapCenterPixles = new Point();
proj.toMapPixels(center, mapCenterPixles);
float radiusPixels = proj.metersToEquatorPixels(newRadius);
IGeoPoint topLeft = proj.fromPixels(mapCenterPixles.x - radiusPixels,
mapCenterPixles.y - radiusPixels);
IGeoPoint bottomRight = proj.fromPixels(mapCenterPixles.x
+ radiusPixels, mapCenterPixles.y + radiusPixels);
m_Map.getController().zoomToSpan(
topLeft.getLatitudeE6() - bottomRight.getLatitudeE6(),
topLeft.getLongitudeE6() - bottomRight.getLongitudeE6());
But it seems i'm missing something, as the values passed to zoomToSpan() cause no chnage, I'm kind of lost here, can someone please shed some light on how to zoom the map to span a bounding box of the circle given its radius in meters, and its center points?
Google Maps zoom levels are defined in powers of two, so MapController#zoomToSpan() also zooms by powers of two.
Ergo, if the span you compute above is already displayable within the current zoom level, it's likely nothing would actually change visually in the map until you need to go to the next larger or smaller zoom level.
This behavior is somewhat vaguely described in the documentation for MapController#zoomToSpan

i want to draw circle around my current location excatly 1 kilometers readius

hi friends i want to draw circle around my current location exactly 1 kilometer radius so wat can i do.....i able to draw circle but how to put radius so it becomes exactly one kilometer..
At a high level:
Get the bounding coordinates of your current map view.
Use your coordinates to compute the distance either horizontally or vertically across your map. Convert your distance to meters, if necessary.
Divide your distance in meters by the horizontal or vertical resolution (in pixels) of your map view. This gives you the number of meters per pixel at your current zoom level.
Evaluate 1000 / <meters per pixel> to determine the number of pixels in 1 kilometer at the current zoom level. This is the radius of your circle.
Draw your circle using the radius you got in step 4.

Categories

Resources