Java Code Examples for org.osmdroid.views.overlay.Marker#setTitle()
The following examples show how to use
org.osmdroid.views.overlay.Marker#setTitle() .
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: MapUtils.java From AndroidApp with Mozilla Public License 2.0 | 7 votes |
public static void addMarker(Context context, MapView map, Element element) { Marker marker = new Marker(map); marker.setPosition(new GeoPoint(element.lat, element.lon)); marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM); map.getOverlays().add(marker); map.invalidate(); marker.setIcon(context.getResources().getDrawable(R.drawable.ic_location)); marker.setTitle(String.valueOf("")); for (Map.Entry<String, String> tag : element.tags.entrySet()) { if (tag.getKey().equals("name")) { marker.setTitle(String.valueOf(tag.getValue())); break; } } if (marker.getTitle().equals("")) marker.setTitle(String.valueOf(element.id)); }
Example 2
Source File: OsmMapShapeConverter.java From osmdroid with Apache License 2.0 | 6 votes |
/** * 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 3
Source File: NativeOpenStreetMapController.java From appinventor-extensions with Apache License 2.0 | 6 votes |
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 4
Source File: MapViewRealTimeActivity.java From Travel-Mate with MIT License | 6 votes |
/** * 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 5
Source File: PlacesOnMapActivity.java From Travel-Mate with MIT License | 6 votes |
/** * 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: AnimatedMarkerHandler.java From osmdroid with Apache License 2.0 | 6 votes |
@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 7
Source File: BookmarkDatastore.java From osmdroid with Apache License 2.0 | 6 votes |
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 8
Source File: AnimatedMarkerValueAnimator.java From osmdroid with Apache License 2.0 | 6 votes |
@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 9
Source File: AnimatedMarkerTypeEvaluator.java From osmdroid with Apache License 2.0 | 6 votes |
@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 10
Source File: IISTrackerBase.java From osmdroid with Apache License 2.0 | 6 votes |
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 11
Source File: SampleSpeechBalloon.java From osmdroid with Apache License 2.0 | 6 votes |
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 12
Source File: MapsActivity.java From Finder with GNU General Public License v3.0 | 5 votes |
private void trackRedraw() { Cursor query = db.query("tracking_table", new String[] {"_id", "lat", "lon", "speed", "date"}, "track_id = ?", new String[] {String.valueOf(track_id)}, null, null, "_id ASC"); Cursor last_point = db.rawQuery("SELECT lat, lon, _id FROM tracking_table WHERE _id = (SELECT MAX(_id) FROM tracking_table WHERE track_id = ?)", new String[] {String.valueOf(track_id)}); last_point.moveToFirst(); Double lat = last_point.getDouble(0); Double lon = last_point.getDouble(1); last_point.close(); //zoom to latest point, because BoundBox don't work in OsmDroid library (this is known lib bug) mapController.setCenter(new GeoPoint(lat, lon)); mapController.setZoom(15d); List<GeoPoint> track = new ArrayList<>(); while (query.moveToNext()) { GeoPoint gp = new GeoPoint(query.getDouble(1), query.getDouble(2)); track.add(gp); Marker marker = new Marker(map); marker.setPosition(gp); marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM); map.getOverlays().add(marker); marker.setTitle(getString(R.string.date_time, query.getString(4), query.getFloat(3))); } query.close(); line.setPoints(track); GeoPoint center = new GeoPoint(lat, lon); mapController.setCenter(center); }
Example 13
Source File: MarkerDrag.java From osmdroid with Apache License 2.0 | 5 votes |
@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 14
Source File: IconPlottingOverlay.java From osmdroid with Apache License 2.0 | 5 votes |
@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 15
Source File: DefaultShapeMetaSetter.java From osmdroid with Apache License 2.0 | 5 votes |
@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 16
Source File: MapUtils.java From AndroidApp with Mozilla Public License 2.0 | 5 votes |
public static void addMarker(Context context, MapView map, double latitude, double longitude, String markerTitle) { Marker marker = new Marker(map); marker.setPosition(new GeoPoint(latitude, longitude)); marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM); map.getOverlays().add(marker); map.invalidate(); marker.setIcon(context.getResources().getDrawable(R.drawable.ic_location)); marker.setTitle(markerTitle); }
Example 17
Source File: MapUtils.java From AndroidApp with Mozilla Public License 2.0 | 5 votes |
/** * Add new {@link Marker} to {@link MapView} * * @param context The context to use. Usually your {@link android.app.Application} or {@link android.app.Activity} object. * @param map {@link MapView} to add marker on * @param position Location of the marker */ public static Marker addMarker(Context context, MapView map, GeoPoint position) { Marker marker = new Marker(map); marker.setPosition(position); marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM); marker.setIcon(context.getResources().getDrawable(R.drawable.ic_location)); marker.setTitle("Latitude: " + position.getLatitude() + "\n" + "Longitude: " + position.getLongitude()); marker.setPanToView(true); marker.setDraggable(true); map.getOverlays().add(marker); map.invalidate(); return marker; }
Example 18
Source File: Plotter.java From osmdroid with Apache License 2.0 | 4 votes |
@Override public void onClick(View v) { switch (v.getId()) { case R.id.radio_milstd2525b: case R.id.radio_milstd2525c: if (((RadioButton) v).isChecked()) { RendererSettings.getInstance().setSymbologyStandard(RendererSettings.Symbology_2525C); } else RendererSettings.getInstance().setSymbologyStandard(RendererSettings.Symbology_2525B); break; case R.id.cancelAddIcon: picker.dismiss(); break; case R.id.addIcon: //from the menu, user entered code String code = symbolCode.getText().toString(); int size = 128; try { size = Integer.parseInt(symbolSize.getText().toString()); } catch (Exception ex) { } String baseCode = SymbolUtilities.getBasicSymbolID(code); SymbolDef def = SymbolDefTable.getInstance().getSymbolDef(baseCode, RendererSettings.getInstance().getSymbologyStandard()); SparseArray<String> attr = new SparseArray<>(); attr.put(MilStdAttributes.PixelSize, size + ""); ImageInfo ii = mir.RenderIcon(code, new SparseArray<String>(), attr); Marker m = new Marker(mMapView); m.setPosition((GeoPoint) mMapView.getMapCenter()); m.setTitle(code); if (def != null) { m.setSubDescription(def.getFullPath()); m.setSnippet(def.getDescription() + "\n" + def.getHierarchy()); } Drawable d = new BitmapDrawable(ii.getImage()); m.setImage(d); m.setIcon(d); int centerX = ii.getCenterPoint().x; //pixel center position //calculate what percentage of the center this value is float realCenterX = (float) centerX / (float) ii.getImage().getWidth(); int centerY = ii.getCenterPoint().y; float realCenterY = (float) centerY / (float) ii.getImage().getHeight(); m.setAnchor(realCenterX, realCenterY); mMapView.getOverlayManager().add(m); mMapView.invalidate(); picker.dismiss(); //TODO store the symbol code and size as an android preference SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(getContext()).edit(); edit.putString("MILSTDCODE", code); RendererSettings.getInstance().setDefaultPixelSize(size); edit.putInt("MILSTDSIZE", size); edit.commit(); break; case R.id.enablePanning: enablePanning(); break; case R.id.enablePainting: enablePainting(); break; } }
Example 19
Source File: MilStdPointPlottingOverlay.java From osmdroid with Apache License 2.0 | 4 votes |
@Override public boolean onLongPress(final MotionEvent e, final MapView mapView) { if (def != null) { GeoPoint pt = (GeoPoint) mapView.getProjection().fromPixels((int) e.getX(), (int) e.getY(), null); //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()); String code = def.getSymbolCode().replace("*", "-"); //TODO if (!def.isMultiPoint()) { int size = 128; SparseArray<String> attr = new SparseArray<>(); attr.put(MilStdAttributes.PixelSize, size + ""); ImageInfo ii = MilStdIconRenderer.getInstance().RenderIcon(code, def.getModifiers(), attr); Marker m = new Marker(mapView); m.setPosition(pt); m.setTitle(code); m.setSnippet(def.getDescription() + "\n" + def.getHierarchy()); m.setSubDescription(def.getPath() + "\n" + m.getPosition().getLatitude() + "," + m.getPosition().getLongitude()); if (ii != null && ii.getImage() != null) { BitmapDrawable d = new BitmapDrawable(ii.getImage()); m.setImage(d); m.setIcon(d); int centerX = ii.getCenterPoint().x; //pixel center position //calculate what percentage of the center this value is float realCenterX = (float) centerX / (float) ii.getImage().getWidth(); int centerY = ii.getCenterPoint().y; float realCenterY = (float) centerY / (float) ii.getImage().getHeight(); m.setAnchor(realCenterX, realCenterY); mapView.getOverlayManager().add(m); mapView.invalidate(); } } return true; } return false; }
Example 20
Source File: MapsActivity.java From Finder with GNU General Public License v3.0 | 4 votes |
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Context ctx = getApplicationContext(); Configuration.getInstance().load(ctx, PreferenceManager.getDefaultSharedPreferences(ctx)); Configuration.getInstance().setUserAgentValue(BuildConfig.APPLICATION_ID); setContentView(R.layout.activity_open_map); SharedPreferences sPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); map = findViewById(R.id.map2); Configuration.getInstance().setTileFileSystemCacheMaxBytes(1024*1024*Long.parseLong(sPref.getString("cache_size", "5"))); Configuration.getInstance().setTileFileSystemCacheTrimBytes(512*1024*Long.parseLong(sPref.getString("cache_size", "5"))); // trim storage to ~50% from max after oversize limit if (sPref.getBoolean("satellite", false)) { final MapBoxTileSource tileSource = new MapBoxTileSource(); tileSource.retrieveAccessToken(this); tileSource.retrieveMapBoxMapId(this); map.setTileSource(tileSource); } else { map.setTileSource(TileSourceFactory.MAPNIK); } map.setBuiltInZoomControls(true); map.setMultiTouchControls(true); mapController = map.getController(); CopyrightOverlay copyOverlay = new CopyrightOverlay(this); copyOverlay.setAlignRight(true); map.getOverlays().add(copyOverlay); ScaleBarOverlay scaleBar= new ScaleBarOverlay(map); scaleBar.setUnitsOfMeasure(ScaleBarOverlay.UnitsOfMeasure.metric); scaleBar.setScaleBarOffset(getResources().getDisplayMetrics().widthPixels/2, 50); scaleBar.setCentred(true); map.getOverlays().add(scaleBar); GpsMyLocationProvider gpsProvider = new GpsMyLocationProvider(this.getBaseContext()); MyLocationNewOverlay myLoc = new MyLocationNewOverlay(gpsProvider, map); myLoc.setDrawAccuracyEnabled(true); map.getOverlays().add(myLoc); CompassOverlay compasOver = new CompassOverlay(this.getBaseContext(), map); compasOver.enableCompass(); map.getOverlays().add(compasOver); dBase baseConnect = new dBase(this); db = baseConnect.getWritableDatabase(); Intent intent = this.getIntent(); mapController.setZoom(intent.getDoubleExtra("zoom", 15.0d)); String act = intent.getAction(); if (act.equals("track")) { track_id = intent.getIntExtra("track_id", 0); line = new Polyline(map); line.setColor(Color.BLUE); line.setInfoWindow(null); //delete popup label from track line.setGeodesic(true); //draw "true" lines instead simple lines (great circles) trackRedraw(); map.getOverlays().add(line); } else { String accuracy = intent.getStringExtra("accuracy"); GeoPoint startPoint = new GeoPoint(intent.getDoubleExtra("lat", 0d), intent.getDoubleExtra("lon", 0d)); mapController.setCenter(startPoint); Marker startMarker = new Marker(map); startMarker.setPosition(startPoint); startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM); map.getOverlays().add(startMarker); startMarker.setTitle(accuracy); } //receiver to map updating LocalBroadcastManager.getInstance(this).registerReceiver(updMap, new IntentFilter("update_map")); }