Anti-Alising Circle shape Google Maps V2 Android - java

Im having problem drawing a Circle using Google Maps v2 . The Circle displays correctly but the circle's edges are not smooth, they are quite sharp, is there any way to apply Antialising to the shape? Thanks
My code:
CircleOptions circleOptions = new CircleOptions()
.center(point)
.radius(500)
.fillColor(0x7F0000FF)
.strokeColor(Color.rgb(71, 143, 150))
.strokeWidth(2);

I know this is an old question, and I'm not completely answering it, but here's my contribute anyhow:
So far I believe there is no way of doing this in Android. The only workaround is to use a Google Maps Marker and replace its icon with a bitmap of a smooth circle. You will not be able to change it's size, but I think that is pretty much the only limitation of not using a Circle object.
To make things easier, you can even use Android Studio to create a new Image asset, choose Clip Art, and search for "brightness". The first icon will be a perfect circle, which you can then change size and color to your taste. Afterwards, just create a new Bitmap from your newly created drawable:
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.DRAWABLE_NAME_HERE);
And create a BitmapDescriptor which is used to give a Google Maps Marker its icon:
BitmapDescriptor descriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
Having this object defined, you just need to set it as your Marker's icon:
Marker.setIcon(descriptor);
or
MarkerOptions.icon(descriptor);
And use these MarkerOptions to create a new Marker.
As I said, this is not the complete answer for your question, but it is the closest thing I know exists. Hope it helps somehow.

Related

how can i make camera preview of circle shape in android?

i am making an android app where the camera preview part is circle so that it will only have to capture the face of the user and beside the circle part make other part black.enter image description here
That would imply making a custom camera yourself instead of using the default one.
Refer to this link for this: https://stackoverflow.com/a/15392209/7528995
You could also use the normal camera instead, since making the user fit their head inside the circled preview would be a bit inconvenient. After capturing the photo you could simply put it into a CircleImageView.
To do this you can refer to this answer: https://stackoverflow.com/a/36613446/7528995

How to display user position on custom made map in indoor navigation?

I am creating a small indoor navigation android application using wifi fingerprinting. Since it is a small scale application I am using a custom made map(which is basically a png image)I want to show the location of the user on a particular spot on the image and update it accordingly as the user moves. So what is the best way to do it?I thought of dividing image like x-y axis and placing the dot on the axis according to value(Tell me this also).
It involves a lot of Bitmap manipulation . Take that marker as an ImageView which you should be able to put it across your FrameLayout inside which you would have the root Map imageView/ map view and then over the top of it . you should be able to put that marker on top of it. but if its a static marker image. then you should be able to use LayoutParams and put on top of the root map view.
There are hundreds of ways.
One easy way would be to use:
https://github.com/chrisbanes/PhotoView
That lib handles scaling, panning, etc and even provides access to the matrix used.
It is important to note too that the users coordinates need to be translated into scale.
In one of my apps, I dont handle user locations, but I allow a user to put pins on the map. My Pin object contains XY coords relative to the original map size.
To convert to the device/image scale size, I do this:
float[] convertedPin = {pin.getX(), pin.getY()};
getImageMatrix().mapPoints(convertedPin);
getImageMatrix() is provided with the library posted above.
Then, I modified the libs onDraw():
for (Pin pin : pins) {
if (pin.isVisible()) {
float[] goal = {pin.getX(), pin.getY()};
getImageMatrix().mapPoints(goal);
if (pin.getPinBitmap() != null) {
float pinSize = TypedValue.applyDimension(COMPLEX_UNIT_DIP, pin.getPinSize(), getContext().getResources().getDisplayMetrics());
canvas.drawBitmap(pin.getPinBitmap(), goal[0] - (pinSize / 2f), goal[1] - pinSize, null);
}
canvas.save();
}
}

Android | GoogleMaps - Merge or combine Circle Borders

Today i saw an picture of an old game. It was an googlemaps based mmorgp, where you could build up your empire. To claim land, you easily builded an flagpole. But im not the best in describing things.
So lets get back to my question. They used googlemaps circles to mark the area of an building, like an flagpole. When a few of those flagpoles were build very close to each other, they merged their borders, that looked like this :
http://imgur.com/a/0hBdK [Wanted to post picture, but stackoverflow image uploader was broken]
So as you can see those circles were "combined". When the border isnt drawn, it looks like they are one big polygon instead of 2 circles. But how to achieve something like that ? Heres how i create a circle :
GoogleMap map;
// ... get a map.
// Add a circle in Sydney
Circle circle = map.addCircle(new CircleOptions()
.center(new LatLng(-33.87365, 151.20689))
.radius(10000)
.strokeColor(Color.RED)
.fillColor(Color.BLUE));
Until now i didnt found any way to merge or combine multiple circles... I didnt even found out how to make the circle border collide with another circle border. Is there a way to do this ?
Thanks for your time and help !^^
The easiest way to do this is calculating the point where those 2 or multiple circles meet each other.

Adding 9000 markers on Google Maps API for Android. App crashes. How to solve?

I have about 9000 areas (i.e. 9000 lines) I have sourced in a CSV file.
There are 6 location related values in each line.
1) I, therefore, have 6 arraylists holding about 9000 values each (doing this in background Async Task) . The size of each of these array lists says "6227" or something like that - so I need to troubleshoot if some values are not being added or is there an arraylist size limitation?
2) Now, I am trying to create 9000 markers with the associated values in the title and snippet section. Please point me to a good tutorial on creating a custom marker with text views. I went to some and couldn't understand anything.
3) My third question is simple: How to efficiently handle this? I am a newcomer and I hate to say that most of the tutorials I have seen on clustering or hiding are impossible to understand. Please provide an understandable description of how to handle this problem. I am begging you.
This is how I collect the data from my CSV file; This is in the background task of AsynTask; And on PostExecute, I pass these values to the method that actually plots the marker on the Google Map.
String mLine = reader.readLine();
while (mLine != null) {
String[] coord = mLine.split(",");
Names.add(coord[0]);
city.add(coord[1]);
country.add(coord[2]);
Code.add(coord[3]);
arrLat=Double.parseDouble(coord[4]);
arrLong=Double.parseDouble(coord[5]);
arrLong=Double.parseDouble(coord[1]);
arrRadius=Double.parseDouble(coord[2]);*/
LatLng thisLoc = new LatLng(arrLat,arrLong);
coordinates.add(thisLoc);
mLine = reader.readLine();
}
For the arraylist size limitation, it should hold up to Integer.MAX_VALUE, you may refer to this link.
I would recommend Clusterer for this particular problem. You may refer to this github sample of MarkerClusterer in which every method has a description, and should be easier to understand. Then, using Viewport Marker Manager to optimize your app's performance. This turns off the markers that are not within the bounds of the screen especially when the user is zooming.
Lastly, in customizing marker with Textview, this link might be helpful. What it does is generate a bitmap and attach it to a marker.
This is the sample code for the custom marker as taken from the link:
Bitmap.Config conf = Bitmap.Config.ARGB_8888;
Bitmap bmp = Bitmap.createBitmap(200, 50, conf);
Canvas canvas = new Canvas(bmp);
canvas.drawText("TEXT", 0, 50, paint); // paint defines the text color, stroke width, size
mMap.addMarker(new MarkerOptions()
.position(clickedPosition)
//.icon(BitmapDescriptorFactory.fromResource(R.drawable.marker2))
.icon(BitmapDescriptorFactory.fromBitmap(bmp))
.anchor(0.5f, 1)
);
Good luck!

Android About Region and Touch

I'm developing an image-processing program. And i'm stuck here.
I have an image like this:
I drew a closed line (path) by finger. Now, I want to get all points in the closed-region cut out from the image. Is there any algorithm or method?
How to create a circular ImageView in Android?
this may help you.
it user drawCircle() to crop a circle, maybe drawPath() can crop a region...

Categories