本文整理汇总了Java中org.osmdroid.views.overlay.Marker.setTitle方法的典型用法代码示例。如果您正苦于以下问题:Java Marker.setTitle方法的具体用法?Java Marker.setTitle怎么用?Java Marker.setTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osmdroid.views.overlay.Marker
的用法示例。
在下文中一共展示了Marker.setTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addMarker
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
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));
}
示例2: setMarkers
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
/**
* Given the request the user is viewing, set the map according to the start and end locations of the trip.
*/
private void setMarkers() {
Marker startMarker = new Marker(map);
startMarker.setIcon(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_start_marker, null));
Marker endMarker = new Marker(map);
endMarker.setIcon(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_end_marker, null));
startMarker.setPosition(startPoint);
startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
startMarker.setTitle("START:\n" + request.getStart().getAddress());
startMarker.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));
endMarker.setPosition(endPoint);
endMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
endMarker.setTitle("END:\n" + request.getEnd().getAddress());
endMarker.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));
map.getOverlays().add(startMarker);
map.getOverlays().add(endMarker);
map.invalidate();
}
示例3: setMarkers
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
/**
* Set the start and end markers based on the exact positions the user gave for them
*/
private void setMarkers() {
// set the map
Marker startMarker = new Marker(map);
startMarker.setIcon(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_start_marker, null));
Marker endMarker = new Marker(map);
endMarker.setIcon(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_end_marker, null));
startMarker.setPosition(startPoint);
startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
startMarker.setTitle("START:\n" + start.getAddress());
startMarker.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));
endMarker.setPosition(endPoint);
endMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
endMarker.setTitle("END:\n" + end.getAddress());
endMarker.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));
map.getOverlays().add(startMarker);
map.getOverlays().add(endMarker);
map.invalidate();
}
示例4: setMarkers
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
/**
* Given the request passed in by the user, set the map according to the start and end locations
*/
private void setMarkers() {
Marker startMarker = new Marker(map);
startMarker.setIcon(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_start_marker, null));
Marker endMarker = new Marker(map);
endMarker.setIcon(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_end_marker, null));
startMarker.setPosition(startPoint);
startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
startMarker.setTitle("START:\n" + request.getStart().getAddress());
startMarker.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));
endMarker.setPosition(endPoint);
endMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
endMarker.setTitle("END:\n" + request.getEnd().getAddress());
endMarker.setInfoWindow(new BasicInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map));
map.getOverlays().add(startMarker);
map.getOverlays().add(endMarker);
map.invalidate();
}
示例5: getLocation
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
/**
* Gets location from ChooseLocationActivity, prints it, and puts it on the map
*/
public void getLocation() {
Intent intent = getIntent();
Gson gson = new Gson();
map.getOverlays().clear();
if (intent.getStringExtra("keyword") != null) {
keyLocation = new Location("");
keyLocation = gson.fromJson(intent.getStringExtra("keyword"), keyLocation.getClass());
}
if (keyLocation == null) {
keywords.setText("");
}
if (keyLocation != null) {
startLocation.setText(keyLocation.getAddress());
Marker locMarker = new Marker(map);
locMarker.setPosition(keyLocation.getGeoLocation());
locMarker.setTitle(keyLocation.getAddress());
locMarker.setIcon(getResources().getDrawable(R.drawable.person));
locMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
map.getOverlays().add(locMarker);
}
}
示例6: putRoadNodes
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
private void putRoadNodes(Road road){
mRoadNodeMarkers.getItems().clear();
Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.marker_node, null);
int n = road.mNodes.size();
MarkerInfoWindow infoWindow = new MarkerInfoWindow(org.osmdroid.bonuspack.R.layout.bonuspack_bubble, map);
TypedArray iconIds = getResources().obtainTypedArray(R.array.direction_icons);
for (int i=0; i<n; i++){
RoadNode node = road.mNodes.get(i);
String instructions = (node.mInstructions==null ? "" : node.mInstructions);
Marker nodeMarker = new Marker(map);
nodeMarker.setTitle(getString(R.string.step)+ " " + (i+1));
nodeMarker.setSnippet(instructions);
nodeMarker.setSubDescription(Road.getLengthDurationText(this, node.mLength, node.mDuration));
nodeMarker.setPosition(node.mLocation);
nodeMarker.setIcon(icon);
nodeMarker.setInfoWindow(infoWindow); //use a shared infowindow.
int iconId = iconIds.getResourceId(node.mManeuverType, R.drawable.ic_empty);
if (iconId != R.drawable.ic_empty){
Drawable image = ResourcesCompat.getDrawable(getResources(), iconId, null);
nodeMarker.setImage(image);
}
mRoadNodeMarkers.add(nodeMarker);
}
iconIds.recycle();
}
示例7: buildOverlay
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
/** Build the corresponding Marker overlay */
@Override public Overlay buildOverlay(MapView map, Style defaultStyle, Styler styler, KmlPlacemark kmlPlacemark,
KmlDocument kmlDocument){
Marker marker = new Marker(map);
marker.setTitle(kmlPlacemark.mName);
marker.setSnippet(kmlPlacemark.mDescription);
marker.setSubDescription(kmlPlacemark.getExtendedDataAsText());
marker.setPosition(getPosition());
//keep the link from the marker to the KML feature:
marker.setRelatedObject(this);
if (styler == null){
applyDefaultStyling(marker, defaultStyle, kmlPlacemark, kmlDocument, map);
} else
styler.onPoint(marker, kmlPlacemark, this);
return marker;
}
示例8: addOverlays
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
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");
}
示例9: onCreateView
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.sample_cachemgr, container,false);
setHasOptionsMenu(false);//prevent tile source changes
mMapView = (MapView) root.findViewById(R.id.mapview);
btnCache = (Button) 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;
}
示例10: addLatLngToMap
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
/**
* 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;
}
示例11: onCreateView
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_osm, container, false);
mUnbinder = ButterKnife.bind(this, view);
GeoPoint startPoint = new GeoPoint(mLat, mLng);
mapView.setTileSource(TileSourceFactory.MAPNIK);
mapView.setBuiltInZoomControls(true);
mapView.setMultiTouchControls(true);
mapView.setMaxZoomLevel(17);
//create the second one
final MapTileProviderBasic ofmTileProvider = new MapTileProviderBasic(getContext());
final ITileSource ofmTileSource = new XYTileSource("OpenFireMap", 10, 17, 256, ".png",
new String[]{"http://openfiremap.org/hytiles/"});
ofmTileProvider.setTileSource(ofmTileSource);
final TilesOverlay ofmTilesOverlay = new TilesOverlay(ofmTileProvider, getContext());
ofmTilesOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);
mapView.getOverlays().add(ofmTilesOverlay);
//Alarm Marker
Marker startMarker = new Marker(mapView);
startMarker.setPosition(startPoint);
startMarker.setTitle(getString(R.string.operation_base));
startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
mapView.getOverlays().add(startMarker);
IMapController mapController = mapView.getController();
mapController.setZoom(startZoomLevel);
mapController.setCenter(startPoint);
return view;
}
示例12: createMarker
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
private Marker createMarker(MapView map, IGeoPointInfo aGeoPoint) {
// final OverlayItem overlayItem = new OverlayItem(aGeoPoint.getId(), aGeoPoint.getName(), aGeoPoint.getDescription(), toOsmGeoPoint(aGeoPoint));
// items.add(overlayItem);
Marker poiMarker = new Marker(map);
poiMarker.setTitle(aGeoPoint.getName());
final String description = aGeoPoint.getDescription();
poiMarker.setSnippet(description);
poiMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
poiMarker.setPosition(toOsmGeoPoint(aGeoPoint));
if (BookmarkUtil.isNotEmpty(description) || BookmarkUtil.isNotEmpty(aGeoPoint.getLink()) || BookmarkUtil.isNotEmpty(aGeoPoint.getName())) {
poiMarker.setIcon(mPoiIconWithData);
// 7.
poiMarker.setInfoWindow(new GeoPointMarkerInfoWindow(map));
} else {
poiMarker.setIcon(mPoiIconWithoutData);
poiMarker.setInfoWindow(null);
}
/*
if (poi.mThumbnail != null){
poiMarker.setImage(new BitmapDrawable(poi.mThumbnail));
}*/
poiMarker.setRelatedObject(aGeoPoint);
return poiMarker;
}
示例13: updateUIWithPOI
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
void updateUIWithPOI(ArrayList<POI> pois, String featureTag){
if (pois != null){
POIInfoWindow poiInfoWindow = new POIInfoWindow(map);
for (POI poi:pois){
Marker poiMarker = new Marker(map);
poiMarker.setTitle(poi.mType);
poiMarker.setSnippet(poi.mDescription);
poiMarker.setPosition(poi.mLocation);
Drawable icon = null;
if (poi.mServiceId == POI.POI_SERVICE_NOMINATIM || poi.mServiceId == POI.POI_SERVICE_OVERPASS_API){
icon = ResourcesCompat.getDrawable(getResources(), R.drawable.marker_poi, null);
poiMarker.setAnchor(Marker.ANCHOR_CENTER, 1.0f);
} else if (poi.mServiceId == POI.POI_SERVICE_GEONAMES_WIKIPEDIA){
if (poi.mRank < 90)
icon = ResourcesCompat.getDrawable(getResources(), R.drawable.marker_poi_wikipedia_16, null);
else
icon = ResourcesCompat.getDrawable(getResources(), R.drawable.marker_poi_wikipedia_32, null);
} else if (poi.mServiceId == POI.POI_SERVICE_FLICKR){
icon = ResourcesCompat.getDrawable(getResources(), R.drawable.marker_poi_flickr, null);
} else if (poi.mServiceId == POI.POI_SERVICE_PICASA){
icon = ResourcesCompat.getDrawable(getResources(), R.drawable.marker_poi_picasa_24, null);
poiMarker.setSubDescription(poi.mCategory);
}
poiMarker.setIcon(icon);
poiMarker.setRelatedObject(poi);
poiMarker.setInfoWindow(poiInfoWindow);
//thumbnail loading moved in async task for better performances.
mPoiMarkers.add(poiMarker);
}
}
mPoiMarkers.setName(featureTag);
mPoiMarkers.invalidate();
map.invalidate();
}
示例14: onLongPress
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
@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() > TileSystem.MaxLatitude)
pt.setLatitude(TileSystem.MaxLatitude);
if (pt.getLatitude() < TileSystem.MinLatitude)
pt.setLatitude(TileSystem.MinLatitude);
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;
}
示例15: addOverlays
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
@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);
}