Clear Part of overlay item in Google Maps in Android - android

In my apps, I have few overlay items,
some are locations of schools,
others is a circle of 30metres around the current point.
As the current location changes from time to time, I want to clear the circle of overlay and redraw it again, however, the locations of schools are fixed, they do not need to change.
The question is, how can I clear part of overlay items?
Thanks a lot!

if you want to clear Overlays
mapView.getOverlays().clear();
and if you want to clear all in mapview
mapView.removeAllViews();
Then refresh your mapview

Related

How Google Maps Android API v2 handle markers outside the view are

During the CameraChange event I add new markers to the map, so I want to know if they are removed automatically when they become invisible as the camera has moved.
Does anyone have this information?
Do you mean, are markers removed when the map is panned such that the marker is no longer on the screen? If so, the answer is no, the markers are still "on the map" even when "off screen".
If you would like to remove markers as they are moved off the map, please see my answer to this question

Giving different id to each marker "overlay" at google maps in Android

I want each marker on the map (Map View) with different id so that I can remove it or change its icon dynamically at run time.
How do we achieve that ?
Also please I want the best way to add many markers on the map without making it slow when moving it on taping over it.
Thanks in advance
How do we achieve that ?
Subclass OverlayItem and store whatever you want in it, using that instead of the ordinary OverlayItem class for your items. For example, this sample project has a CustomItem subclass of OverlayItem that, among other things, draws different icons at runtime.
Also please I want the best way to add many markers on the map without making it slow when moving it on taping over it
Don't "add many markers" to an ItemizedOverlay, to the point where it is "when moving it on taping over it". ItemizedOverlay is designed for small numbers of items.
If you need lots of items, you will most likely need to create your own Overlay, where you can have more smarts about which subset of your items will be relevant at any given time.

Ballon on Mapview and also want to get location whenever balloon position changed on Map in android

Recently I show the ubicabs taxi booking app. I found very nice functionality inside it. In this app they have google maps for showing markers, but they have used very good UI component for that. Also I found one more uniqueness is that whenever user moves or change the position of marker through touch it will fetch the current location. One thing that I know is that it is using the onTouchEvent of Overlay but how to create that marker balloon and how to get updated location on the basis of that marker.
I am attaching a preview of that marker here. Also would like to know that how can we scroll the text inside that balloon?
The best overlay open project I have found so far is this one, link. But it is nothing compared to the picture above. Would also like to know how they created this! Great Question and picture ;)

Android: Move point on the google map when clicking somewhere on the map

I want to give my users oppertinty to choose destination. from the beginning it will already have a point on the map, and after that they can choose/change to another location if they want..
how is it possible to change the point on the map, by clicking somewhere else on the map?
I assume you're talking about a MapView within your application, and not in the Google Maps app. There's a method on a MapView called onTouchEvent(). This callback will be called when a user clicks (or touches) on the map, and you can read the location of the touch from the MotionEvent object that's passed in. From there you can decide what you want to do.
Another way is to extend the Overlay class, and add it to your MapView's Overlay list. Overlay has a method called onTap(), which gives you the GeoPoint where the touch took place. You can then animate to that spot using the MapController to center the map on that spot.
If all you want to do is pan the map sideways, a user can simply touch and drag the map.
For these things to work the MapView must be clickable (settable in XML or with code).
The relevant reference pages are here:
URL to Android Maps API
i think this tutorial is perfect one. You should read carefully content of source code. That's all what u need to do.

How to save coordinates with Google Map?

I'm currently developing an app which uses tabs and google map. What I want to do is to get the gps positions, say 3, and store them in sql db (which I'm already doing) and then display them on the map. I already created canvas, added to overlay but those points disappear when I'm changing tabs so I thought if there is a way to somehow store those coords with google map so I can retrieve them and display them nicely whenever I'm clicking the "map tab"? Please can anyone help?
I don't have the answer for you but I know the issue is being caused by the change of view. This is the same as you get when you rotate the device and the screen resets. You need to do something with the onRestoreInstanceState(). The default of this restores the state of your UI. So you need to override it to save the data and readd it when the view changes.
Hope that helps. Someone else might have a code sample.
T
Use an ItemizedOverlay, and associate the overlay with the map in onCreate(). The overlay should not "disappear when I'm changing tabs".

Categories

Resources