org.osmdroid.views.overlay.Marker Java Examples

The following examples show how to use org.osmdroid.views.overlay.Marker. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MapFragment.java    From AndroidApp with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mapSetup();
    viewSetup();

    if (map != null && (existingRoute = ((MainActivity) getActivity()).getMapRoute()) != null && ((MainActivity) getActivity()).getRouteMarker() != null) {
        //load routes if any previously exit
        map.getOverlays().add(existingRoute);
        Marker marker = ((MainActivity) getActivity()).getRouteMarker();
        routeDestinationMarker = MapUtils.addMarker(getActivity(), map, marker.getPosition().getLatitude(), marker.getPosition().getLongitude());
        map.invalidate();

        ((MainActivity) getActivity()).toggleFabPoiDetailsAfterRoute();
        //restart the route redraw timer if there is a route to some destination
        overrideRouteOnLocationChange();
    }
}
 
Example #2
Source File: BookmarkDatastore.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
public List<Marker> getBookmarksAsMarkers(MapView view) {
    List<Marker> markers = new ArrayList<>();
    try {
        //TODO order by title
        final Cursor cur = mDatabase.rawQuery("SELECT * FROM " + TABLE, null);
        while(cur.moveToNext()) {
            Marker m = new Marker(view);
            m.setId(cur.getString(cur.getColumnIndex(COLUMN_ID)));
            m.setTitle(cur.getString(cur.getColumnIndex(COLUMN_TITLE)));
            m.setSubDescription(cur.getString(cur.getColumnIndex(COLUMN_DESC)));
            m.setPosition(new GeoPoint(cur.getDouble(cur.getColumnIndex(COLUMN_LAT)),cur.getDouble(cur.getColumnIndex(COLUMN_LON))));
            m.setSnippet(m.getPosition().toDoubleString());

            markers.add(m);
        }
        cur.close();
    } catch (final Exception e) {
        Log.w(IMapView.LOGTAG,"Error getting tile sources: ", e);
    }
    return markers;
}
 
Example #3
Source File: FragmentiGapMap.java    From iGap-Android with GNU Affero General Public License v3.0 6 votes vote down vote up
private void drawMark(final OverlayItem mapItem, final boolean hasComment, final long userIdR) {

        if (userIdR == 0) {
            return;
        }

        G.handler.post(new Runnable() {
            @Override
            public void run() {
                Marker marker = new Marker(map);
                marker.setPosition(new GeoPoint(mapItem.getPoint().getLatitude(), mapItem.getPoint().getLongitude()));
                InfoWindow infoWindow;
                marker.setIcon(avatarMark(userIdR, MarkerColor.GRAY));
                infoWindow = new MyInfoWindow(map, marker, userIdR, hasComment, FragmentiGapMap.this, G.fragmentActivity);
                marker.setInfoWindow(infoWindow);

                markers.add(marker);
                map.getOverlays().add(marker);
                map.invalidate();
            }
        });
    }
 
Example #4
Source File: OsmMapShapeConverter.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
/**
 * Add a LatLng to the map
 *
 * @param map
 * @param latLng
 * @param options
 * @return
 */
public static Marker addLatLngToMap(MapView map, GeoPoint latLng,
                                    MarkerOptions options) {
    Marker m = new Marker(map);
    m.setPosition(latLng);
    if (options!=null) {
        if (options.getIcon()!=null){
            m.setIcon(options.getIcon());
        }
        m.setAlpha(options.getAlpha());
        m.setTitle(options.getTitle());
        m.setSubDescription(options.getSubdescription());
        m.setInfoWindow(new BasicInfoWindow(R.layout.bonuspack_bubble, map));
    }
    map.getOverlayManager().add(m);
    return m;
}
 
Example #5
Source File: PlacesOnMapActivity.java    From Travel-Mate with MIT License 6 votes vote down vote up
/**
 * show marker
 *
 * @param locationLat  latitude
 * @param locationLong longitude
 * @param locationName name of location
 */
private void showMarker(Double locationLat, Double locationLong, String locationName) {
    GeoPoint coord = new GeoPoint(locationLat, locationLong);
    Marker marker = new Marker(mMap);
    if (ContextCompat.checkSelfPermission(PlacesOnMapActivity.this,
            Manifest.permission.ACCESS_COARSE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
        marker.setPosition(coord);
        marker.setIcon(mMarker);
        marker.setTitle(locationName);
        marker.setOnMarkerClickListener(this);
        mMap.getOverlays().add(marker);
        mMap.invalidate();
        mMarkerList.add(marker);
    }
}
 
Example #6
Source File: SampleMilitaryIconsMarker.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
private void addIcons(int count) {
     for (int i = 0; i < count; i++) {
          double random_lon = MapView.getTileSystem().getRandomLongitude(mRandom.nextDouble());
          double random_lat = MapView.getTileSystem().getRandomLatitude(mRandom.nextDouble());
          Marker m = new Marker(mMapView);
          m.setPosition(new GeoPoint(random_lat, random_lon));
          final int index = mRandom.nextInt(icons.size());
          m.setSnippet("A random point");
          m.setSubDescription("location: " + random_lat + "," + random_lon);
          m.setIcon(icons.get(index));
          mMapView.getOverlayManager().add(m);
     }

     mMapView.invalidate();
     Toast.makeText(getActivity(), count + " icons added! Current size: " + mMapView.getOverlayManager().size(), Toast.LENGTH_SHORT).show();

}
 
Example #7
Source File: IISTrackerBase.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
protected void addOverlays() {
    super.addOverlays();

    mMapView.setTilesScaledToDpi(true);
    mMapView.getController().setZoom(3);

    cm = (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);

    image = getResources().getDrawable(R.drawable.sfppt);
    icon =getResources().getDrawable(R.drawable.sfppt_small);
    //icon_old=getResources().getDrawable(R.drawable.sfppt_small);
    //icon_old.setAlpha(77);

    marker = new Marker(mMapView);
    marker.setImage(image);
    marker.setIcon(icon);
    marker.setTitle("International Space Station");


}
 
Example #8
Source File: SampleSpeechBalloon.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
private void addToDisplay(final POI pPOI) {
    final Marker marker = new Marker(mMapView);
    marker.setTitle(pPOI.mTitle);
    marker.setPosition(pPOI.mGeoPoint);
    marker.setIcon(mBitmapDrawable);
    mMapView.getOverlays().add(marker);
    if (pPOI.mSpeechBalloon) {
        final SpeechBalloonOverlay speechBalloonOverlay = new SpeechBalloonOverlay();
        speechBalloonOverlay.setTitle(pPOI.mTitle);
        speechBalloonOverlay.setMargin(10);
        speechBalloonOverlay.setRadius(15);
        speechBalloonOverlay.setGeoPoint(new GeoPoint(pPOI.mGeoPoint));
        speechBalloonOverlay.setOffset(pPOI.mOffsetX, pPOI.mOffsetY);
        speechBalloonOverlay.setForeground(mForeground);
        speechBalloonOverlay.setBackground(mBackground);
        speechBalloonOverlay.setDragForeground(mDragForeground);
        speechBalloonOverlay.setDragBackground(mDragBackground);
        mMapView.getOverlays().add(speechBalloonOverlay);
    }
}
 
Example #9
Source File: AnimatedMarkerTimer.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
@Override
protected void addOverlays() {
    super.addOverlays();
    mMapView.getController().setCenter(new GeoPoint(0d, 0d));
    mMapView.getController().setZoom(5);
    mMapView.setTilesScaledToDpi(true);
    mMapView.setMapListener(this);
    mMapView.getController().setZoom(3);

    marker = new Marker(mMapView);
    marker.setPosition(new GeoPoint(45d, -74d));

    LatLonGridlineOverlay2 grids = new LatLonGridlineOverlay2();

    grids.setBackgroundColor(Color.BLACK);
    grids.setFontColor(Color.GREEN);
    grids.setLineColor(Color.GREEN);
    mMapView.getOverlayManager().add(grids);

}
 
Example #10
Source File: MapFragment.java    From AndroidApp with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Redraw the route form source to destination
 */
private void overrideRouteOnLocationChange() {
    if (existingRoute != null) {
        routeUpdateTimer = new Timer();
        routeUpdateTimer.scheduleAtFixedRate(new TimerTask() {
            @Override
            public void run() {
                //Redraw route every 15 seconds when the user moves on the map
                //clear existing Route
                if (existingRoute != null && map != null)
                    map.getOverlays().remove(existingRoute);
                //clear data from MainActivity
                ((MainActivity) getActivity()).clearRoutePolyline();

                Marker destinationMarker = ((MainActivity) getActivity()).getRouteMarker();
                DeviceLocationData location = ((MainActivity) getActivity()).getLastKnownLocation();
                if (location != null && destinationMarker != null)
                    createRoute(location.getLatitude(), location.getLongitude(), destinationMarker.getPosition().getLatitude(), destinationMarker.getPosition().getLongitude());

            }
        }, 5000, 15000);// First time start after 5 seconds and repeat after 15 seconds
    }
}
 
Example #11
Source File: AnimatedMarkerTypeEvaluator.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {


    View root = inflater.inflate(R.layout.sample_cachemgr, container,false);
    mMapView = new MapView(getActivity());
    ((LinearLayout) root.findViewById(R.id.mapview)).addView(mMapView);
    btnCache = root.findViewById(R.id.btnCache);
    btnCache.setOnClickListener(this);
    btnCache.setText("Start/Stop Animation");

    marker = new Marker(mMapView);
    marker.setTitle("An animated marker");
    marker.setPosition(new GeoPoint(0d,0d));
    mMapView.getOverlayManager().add(marker);



    return root;
}
 
Example #12
Source File: MapViewRealTimeActivity.java    From Travel-Mate with MIT License 6 votes vote down vote up
/**
 * Sets marker at given location on map
 *
 * @param locationLat  latitude
 * @param locationLong longitude
 * @param locationName name of location
 * @param locationIcon icon
 */
private void showMarker(Double locationLat, Double locationLong, String locationName, Integer locationIcon) {
    GeoPoint coord = new GeoPoint(locationLat, locationLong);
    Marker marker = new Marker(mMap);

    if (ContextCompat.checkSelfPermission(MapViewRealTimeActivity.this,
            Manifest.permission.ACCESS_COARSE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
        marker.setPosition(coord);
        marker.setIcon(this.getDrawable(locationIcon));
        marker.setTitle(locationName);
        marker.setOnMarkerClickListener(this);

        mMap.getOverlays().add(marker);
        mMap.invalidate();
    }
}
 
Example #13
Source File: PlacesOnMapActivity.java    From Travel-Mate with MIT License 6 votes vote down vote up
/**
 * on marker selected
 *
 * @param marker marker
 */
private void onPlaceSelected(Marker marker) {
    try {
        moveMakerToCenter(marker, marker.getPosition().getLatitude(), marker.getPosition().getLongitude());
        linearLayout.setVisibility(View.VISIBLE);
        selectedItemName.setText(marker.getTitle());
        String[] address = mFeedItems.getJSONObject(mIndex).getString("address").split("<br/>");
        if (address.length > 1) {
            selectedItemAddress.setText(address[0] + ", " + address[1]);
        } else {
            selectedItemAddress.setText(address[0]);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
 
Example #14
Source File: AnimatedMarkerValueAnimator.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {


    View root = inflater.inflate(R.layout.sample_cachemgr, container,false);
    mMapView = new MapView(getActivity());
    ((LinearLayout) root.findViewById(R.id.mapview)).addView(mMapView);
    btnCache = root.findViewById(R.id.btnCache);
    btnCache.setOnClickListener(this);
    btnCache.setText("Start/Stop Animation");

    marker = new Marker(mMapView);
    marker.setTitle("An animated marker");
    marker.setPosition(new GeoPoint(0d,0d));
    mMapView.getOverlayManager().add(marker);



    return root;
}
 
Example #15
Source File: NativeOpenStreetMapController.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
private void createNativeMarker(final MapMarker aiMarker,
    AsyncCallbackPair<Marker> callback) {
  final Marker osmMarker = new Marker(view);
  featureOverlays.put(aiMarker, osmMarker);
  osmMarker.setDraggable(aiMarker.Draggable());
  osmMarker.setTitle(aiMarker.Title());
  osmMarker.setSnippet(aiMarker.Description());
  osmMarker.setPosition(new GeoPoint(aiMarker.Latitude(), aiMarker.Longitude()));
  osmMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
  getMarkerDrawable(aiMarker, new AsyncCallbackFacade<Drawable, Marker>(callback) {
    @Override
    public void onFailure(String message) {
      callback.onFailure(message);
    }

    @Override
    public void onSuccess(Drawable result) {
      osmMarker.setIcon(result);
      callback.onSuccess(osmMarker);
    }
  });
}
 
Example #16
Source File: NativeOpenStreetMapController.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public void updateFeatureSize(MapMarker aiMarker) {
  final Marker marker = (Marker)featureOverlays.get(aiMarker);
  if (marker == null) {
    return;
  }
  getMarkerDrawable(aiMarker, new AsyncCallbackPair<Drawable>() {
    @Override
    public void onFailure(String message) {
      Log.wtf(TAG, "Cannot find default marker");
    }

    @Override
    public void onSuccess(Drawable result) {
      marker.setIcon(result);
      view.invalidate();
    }
  });
}
 
Example #17
Source File: NativeOpenStreetMapController.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public void updateFeatureImage(MapMarker aiMarker) {
  final Marker marker = (Marker)featureOverlays.get(aiMarker);
  if (marker == null) {
    return;  // not yet initialized
  }
  getMarkerDrawable(aiMarker, new AsyncCallbackPair<Drawable>() {
    @Override
    public void onFailure(String message) {
      Log.e(TAG, "Unable to update feature image: " + message);
    }

    @Override
    public void onSuccess(Drawable result) {
      marker.setIcon(result);
      view.invalidate();
    }
  });
}
 
Example #18
Source File: AnimatedMarkerHandler.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {


    View root = inflater.inflate(R.layout.sample_cachemgr, container,false);
    mMapView = new MapView(getActivity());
    ((LinearLayout) root.findViewById(R.id.mapview)).addView(mMapView);
    btnCache = root.findViewById(R.id.btnCache);
    btnCache.setOnClickListener(this);
    btnCache.setText("Start/Stop Animation");

    marker = new Marker(mMapView);
    marker.setTitle("An animated marker");
    marker.setPosition(new GeoPoint(0d,0d));
    mMapView.getOverlayManager().add(marker);



    return root;
}
 
Example #19
Source File: PlacesOnMapActivity.java    From Travel-Mate with MIT License 6 votes vote down vote up
/**
 * Highlights the marker whose card is clicked
 *
 * @param title this is the title of the marker
 */
private void highlightMarker(String title) {
    int index = 0;
    Marker currentMarker = null;
    for (Marker m : mMarkerList) {
        if (m.getTitle().equals(title)) {
            currentMarker = mMarkerList.get(index);
            break;
        }
        index++;
    }
    if (mPreviousMarker != null) {
        mPreviousMarker.setIcon(mMarker);
        //hide info about previous marker
        mPreviousMarker.closeInfoWindow();
    }
    mMap.getOverlays().remove(currentMarker);
    mMap.invalidate();
    currentMarker.setIcon(mDefaultMarker);
    mMap.getOverlays().add(currentMarker);
    mMap.invalidate();
    //show info about current marker
    currentMarker.showInfoWindow();
    mPreviousMarker = currentMarker;
    zoomToMarker(currentMarker.getPosition().getLatitude(), currentMarker.getPosition().getLongitude());
}
 
Example #20
Source File: MarkerInfoWindow.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
@Override public void onOpen(Object item) {
	super.onOpen(item);
	
	mMarkerRef = (Marker)item;
	if (mView==null) {
		Log.w(IMapView.LOGTAG, "Error trapped, MarkerInfoWindow.open, mView is null!");
		return;
	}
	//handle image
	ImageView imageView = (ImageView)mView.findViewById(mImageId /*R.id.image*/);
	Drawable image = mMarkerRef.getImage();
	if (image != null){
		imageView.setImageDrawable(image); //or setBackgroundDrawable(image)?
		imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
		imageView.setVisibility(View.VISIBLE);
	} else
		imageView.setVisibility(View.GONE);
}
 
Example #21
Source File: IconPlottingOverlay.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onLongPress(final MotionEvent e, final MapView mapView) {
    if (markerIcon != null) {
        GeoPoint pt = (GeoPoint) mapView.getProjection().fromPixels((int) e.getX(), (int) e.getY(), null);
        /*
         * <b>Note</b></b: when plotting a point off the map, the conversion from
             * screen coordinates to map coordinates will return values that are invalid from a latitude,longitude
             * perspective. Sometimes this is a wanted behavior and sometimes it isn't. We are leaving it up to you,
             * the developer using osmdroid to decide on what is right for your application. See
             * <a href="https://github.com/osmdroid/osmdroid/pull/722">https://github.com/osmdroid/osmdroid/pull/722</a>
             * for more information and the discussion associated with this.
         */

        //just in case the point is off the map, let's fix the coordinates
        if (pt.getLongitude() < -180)
            pt.setLongitude(pt.getLongitude()+360);
        if (pt.getLongitude() > 180)
            pt.setLongitude(pt.getLongitude()-360);
        //latitude is a bit harder. see https://en.wikipedia.org/wiki/Mercator_projection
        if (pt.getLatitude() > mapView.getTileSystem().getMaxLatitude())
            pt.setLatitude(mapView.getTileSystem().getMaxLatitude());
        if (pt.getLatitude() < mapView.getTileSystem().getMinLatitude())
            pt.setLatitude(mapView.getTileSystem().getMinLatitude());

        Marker m = new Marker(mapView);
        m.setPosition(pt);
        m.setIcon(markerIcon);
        m.setImage(markerIcon);
        m.setTitle("A demo title");
        m.setSubDescription("A demo sub description\n" + pt.getLatitude() + "," + pt.getLongitude());
        m.setSnippet("a snippet of information");
        mapView.getOverlayManager().add(m);
        mapView.invalidate();
        return true;
    }
    return false;
}
 
Example #22
Source File: MultiMarker.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setVisibleMarkers(boolean visible) {
    for (Marker marker : markers) {
        marker.setVisible(visible);
    }
}
 
Example #23
Source File: WeathForceActivity.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_starter_mapview);

    Intent intent = getIntent();
    //if (intent)
    final double lat1 = 25.633;
    final double long1 = 71.094;

    //super important. Many tile servers, including open street maps, will BAN applications by user
    //agent. Do not use the sample application's user agent for your app! Use your own setting, such
    //as the app id.
    Configuration.getInstance().setUserAgentValue(getPackageName());

    mMapView = findViewById(R.id.mapview);
    mMapView.setTileSource(TileSourceFactory.MAPNIK);


    mCompassOverlay = new CompassOverlay(this, new InternalCompassOrientationProvider(this),
            mMapView);
    mCompassOverlay.enableCompass();
    mMapView.getOverlays().add(this.mCompassOverlay);

    addOverlays();

    GeoPoint startPoint = new GeoPoint(lat1, long1);
    IMapController mapController = mMapView.getController();
    mapController.setZoom(9);
    mapController.setCenter(startPoint);
    Marker startMarker = new Marker(mMapView);
    startMarker.setPosition(startPoint);
    startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
    mMapView.getOverlays().add(startMarker);


    mMapView.invalidate();

}
 
Example #24
Source File: MarkerAnimation.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public static ObjectAnimator animateMarkerToICS(final MapView map, Marker marker, GeoPoint finalPosition, final GeoPointInterpolator GeoPointInterpolator) {
    TypeEvaluator<GeoPoint> typeEvaluator = new TypeEvaluator<GeoPoint>() {
        @Override
        public GeoPoint evaluate(float fraction, GeoPoint startValue, GeoPoint endValue) {
            return GeoPointInterpolator.interpolate(fraction, startValue, endValue);
        }
    };
    Property<Marker, GeoPoint> property = Property.of(Marker.class, GeoPoint.class, "position");
    ObjectAnimator animator = ObjectAnimator.ofObject(marker, property, typeEvaluator, finalPosition);
    animator.setDuration(3000);
    animator.start();
    return animator;
}
 
Example #25
Source File: ChatAttachAlertLocationLayout.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void removeInfoView(Marker marker) {
    View view = views.get(marker);
    if (view != null) {
        removeView(view);
        views.remove(marker);
    }
}
 
Example #26
Source File: MarkerDrag.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
@Override
public void addOverlays(){
    super.addOverlays();
    //0. Using the Marker overlay
    Marker startMarker = new Marker(mMapView);
    startMarker.setPosition(new GeoPoint(0.0,0.0));
    startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
    startMarker.setTitle("Start point");
    startMarker.setDraggable(true);
    startMarker.setOnMarkerDragListener(new OnMarkerDragListenerDrawer());
    mMapView.getOverlays().add(startMarker);

}
 
Example #27
Source File: SampleCustomMyLocation.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
@Override
public void addOverlays() {
    super.addOverlays();
    myLocation = new Marker(mMapView);
    myLocation.setIcon(getResources().getDrawable(org.osmdroid.R.drawable.icon));
    myLocation.setImage(getResources().getDrawable(org.osmdroid.R.drawable.icon));


}
 
Example #28
Source File: DefaultShapeMetaSetter.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
@Override
public void set(DbfRecord metadata, Marker marker) throws ParseException {
    if (metadata != null) {
        metadata.setStringCharset(Charset.defaultCharset());
        marker.setSnippet(metadata.toMap().toString());
        marker.setTitle(getSensibleTitle(marker.getSnippet()));
    }
}
 
Example #29
Source File: ChatAttachAlertLocationLayout.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void updatePositions() {
    if (mapView == null) {
        return;
    }
    Projection projection = mapView.getProjection();
    for (HashMap.Entry<Marker, View> entry : views.entrySet()) {
        Marker marker = entry.getKey();
        View view = entry.getValue();
        Point point = projection.toPixels(marker.getPosition(),null);
        view.setTranslationX(point.x - view.getMeasuredWidth() / 2);
        view.setTranslationY(point.y - view.getMeasuredHeight() + AndroidUtilities.dp(22));
    }
}
 
Example #30
Source File: LocationActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void removeInfoView(Marker marker) {
    View view = views.get(marker);
    if (view != null) {
        removeView(view);
        views.remove(marker);
    }
}