本文整理汇总了Java中org.osmdroid.views.overlay.Marker.setAnchor方法的典型用法代码示例。如果您正苦于以下问题:Java Marker.setAnchor方法的具体用法?Java Marker.setAnchor怎么用?Java Marker.setAnchor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osmdroid.views.overlay.Marker
的用法示例。
在下文中一共展示了Marker.setAnchor方法的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: createCustomMarker
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
public Marker createCustomMarker(MapView mapView, Drawable markerIcon, GeoPoint location, @Nullable Marker.OnMarkerClickListener clickListener){
Marker poiMarker = new Marker(mapView);
poiMarker.setAnchor(0.5f,1);
poiMarker.setPosition(location);
if(markerIcon == null){
throw new NullMarkerDrawableException("You must choose a drawable asset for your Marker");
}
poiMarker.setIcon(markerIcon);
if(clickListener != null){
poiMarker.setOnMarkerClickListener(clickListener);
}
return poiMarker;
}
示例6: 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);
}
}
示例7: buildClusterMarker
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
@Override public Marker buildClusterMarker(StaticCluster cluster, MapView mapView) {
Marker m = new Marker(mapView);
m.setPosition(cluster.getPosition());
m.setInfoWindow(null);
m.setAnchor(mAnchorU, mAnchorV);
Bitmap finalIcon = Bitmap.createBitmap(mClusterIcon.getWidth(), mClusterIcon.getHeight(), mClusterIcon.getConfig());
Canvas iconCanvas = new Canvas(finalIcon);
iconCanvas.drawBitmap(mClusterIcon, 0, 0, null);
String text = "" + cluster.getSize();
int textHeight = (int) (mTextPaint.descent() + mTextPaint.ascent());
iconCanvas.drawText(text,
mTextAnchorU * finalIcon.getWidth(),
mTextAnchorV * finalIcon.getHeight() - textHeight / 2,
mTextPaint);
m.setIcon(new BitmapDrawable(mapView.getContext().getResources(), finalIcon));
return m;
}
示例8: buildClusterMarker
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
/** Build the marker for a cluster.
* Uses the cluster icon, and displays inside the number of markers it contains. <br/>
* In the standard Google coordinate system for Marker icons: <br/>
* - The cluster icon is anchored at mAnchorU, mAnchorV. <br/>
* - The text showing the number of markers is anchored at mTextAnchorU, mTextAnchorV.
* This text is centered horizontally and vertically. */
@Override public Marker buildClusterMarker(StaticCluster cluster, MapView mapView){
Marker m = new Marker(mapView);
m.setPosition(cluster.getPosition());
m.setInfoWindow(null);
m.setAnchor(mAnchorU, mAnchorV);
Bitmap finalIcon = Bitmap.createBitmap(mClusterIcon.getWidth(), mClusterIcon.getHeight(), mClusterIcon.getConfig());
Canvas iconCanvas = new Canvas(finalIcon);
iconCanvas.drawBitmap(mClusterIcon, 0, 0, null);
String text = ""+cluster.getSize();
int textHeight = (int) (mTextPaint.descent() + mTextPaint.ascent());
iconCanvas.drawText(text,
mTextAnchorU*finalIcon.getWidth(),
mTextAnchorV*finalIcon.getHeight() - textHeight/2,
mTextPaint);
m.setIcon(new BitmapDrawable(mapView.getContext().getResources(), finalIcon));
return m;
}
示例9: myLocation
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
public static Marker myLocation(Context context, MapView map, double latitude, double longitude) {
if (map == null || context == null) return null;
Marker marker = new Marker(map);
marker.setPosition(new GeoPoint(latitude, longitude));
marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
marker.setIcon(context.getResources().getDrawable(R.drawable.ic_gps_location));
marker.setInfoWindow(null);
map.getOverlays().add(marker);
map.invalidate();
return marker;
}
示例10: 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;
}
示例11: buildClusterMarker
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
@Override public Marker buildClusterMarker(StaticCluster cluster, MapView mapView) {
Marker m = new Marker(mapView);
m.setPosition(cluster.getPosition());
final InfoWindow infoWindow = (cluster.getSize() > 0) ? cluster.getItem(0).getInfoWindow() : null;
m.setInfoWindow(infoWindow);
m.setAnchor(mAnchorU, mAnchorV);
final BitmapDrawable icon = getClusterMarkerIcon("" + cluster.getSize(), mapView);
m.setIcon(icon);
setRadius(48);
return m;
}
示例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: getInnerMarker
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
private Marker getInnerMarker(){
Marker marker = new Marker(getMapView());
//TODO(aantoine): add new drawable
/*marker.setIcon(ContextCompat.getDrawable(getMapView().getContext(),
R.drawable.bordered_circle));*/
marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_CENTER);
return marker;
}
示例14: 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();
}
示例15: styleMarker
import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
/** apply all IconStyle attributes to the Marker */
public void styleMarker(Marker marker, Context context){
BitmapDrawable icon = getFinalIcon(context);
if (icon != null) {
marker.setIcon(icon);
marker.setAnchor(mHotSpot.getX(icon.getIntrinsicWidth() / mScale),
1.0f - mHotSpot.getY(icon.getIntrinsicHeight() / mScale));
} //else, default Marker icon will be used.
//Y coords are top->bottom for Marker Anchor, and bottom->up for KML hotSpot
marker.setRotation(mHeading);
}