Question : How do I create a 9000 meters buffer radius from a point and display placemarks that intersect that buffer.
Answer : Google Map API for android has a class that reads and draw your current location in the map.
That class is "MyLocationOverlay". The class has a "draw" method that will be called everytime user pan or zoom on the map.
So to draw a circle radius of your current location, we need to extends this class and override its draw method.
Then, we create our view, one map view, one textbox and one button
After that, we need to create our main class. TukangAndroidApp.java
Dont forget to edit AndroidManifest.xml to add permissions and google map library
Run your application.
Tips : Set the GPS location from the DDMS first before you press Search, otherwise you will encounter NullPointerException
If all goes well, your application will be like this
Notice in TukangAndroidApp.java, our displayResult method didnt do anything, so we will implement the method to return some placemarks that intersect our buffer.
First, we should extends ItemizedOverlay class to create our placemark
Next, we will implement the displayResult method.
Our last TukangAndroidApp.java should look like this
Run the application, and you can see that our application will work well.
Have fun!
Perfect........I was looking for hours this code....
ReplyDeleteHow can i get the current location
ReplyDeleteWhy does this application crashes after some time?
ReplyDelete@CEC@IT open DDMS view, click Emulator Control button (nearly top of the screen), after that you will see Location Controls.
ReplyDeletecan some one plz upload the zip file as i cant get the code working
ReplyDeleteThat was awesome
ReplyDeleteI follow your step but when I try to implement the displayResult method , It's has stopped.
Awesome! Just what I was looking for..tiny question..I need to show a list of locations surrounded by the circle definigng the radius.
ReplyDeleteWhat can I do to make sure I add the markers and draw the circle at the same time?
why does the circle disappear when I zoom passed a certain zoom level?
ReplyDeleteGreat work.. thanks a lot.... This article did many things to me...
ReplyDeletedoes it applicable in GMap v2?
ReplyDeletelike...!!!
DeleteCan you give me a full project of this application ?
ReplyDeleteI don't get it how these things work.
Can you help soving this problem http://stackoverflow.com/questions/33035373/show-markers-near-the-device-in-android/33037739#33037739 ?
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteGreat Article
ReplyDeleteJava Web Services Online Training
Web Services Course
Web Services Training Courses
Java Web Services Training in Chennai
Hi, is it possible to maybe provide us with a source code, more like a Github link if you do not mind..
ReplyDelete