Issue
I use android-mapviewballoons library to show balloons. So, once user clicks on my marker, balloon is shown.
The question I have: how to display the balloon for particular item without waiting for user click?
Upd. how to identify i? Currently I have the following:
public class Map extends MapActivity {
public void onCreate(Bundle savedInstanceState) {
// here I have extras.getDouble("lat") and extras.getDouble("lng") -
// the location balloon should be shown for
...
itemizedOverlay = new MapOverlay(drawable, mapView);
for (int i = 0; i < items.getCount(); i++) {
// here I add markers, one of them will have lat and lng equal to
// the values passed in extras
public class MapOverlay extends BalloonItemizedOverlay<OverlayItem> {
...
protected OverlayItem createItem(int i) {
Also, with regards to the following code:
// BalloonOverlayView is a raw type. References to generic type BalloonOverlayView<Item> should be parameterized
BalloonOverlayView bov = new BalloonOverlayView(context, 50);
// What is item there? should be getItem(i)?
bov.setData(item);
// The method setPosition(int) is undefined for the type BalloonOverlayView
BalloonOverlayView.setPosition(i);
Solution
Plase refer this tutorial.
In @Override protected OverlayItem createItem(int i) method you can inflate that ballon ovarlay for your particular index. suppose your specific point is 2 then you can do following in above method
if(i==2){
BalloonOverlayView bov = new BalloonOverlayView(context, 50);
bov.setData(item);
BalloonOverlayView.setPosition(i);
BalloonOverlayView.setGeoPoint(geoPoint);
MapView.LayoutParams params = new MapView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, geoPoint,MapView.LayoutParams.BOTTOM_CENTER);
params.mode=MapView.LayoutParams.MODE_MAP;
mapView.addView(bov, params);
}
Answered By - Harshad
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.