本文整理汇总了Java中org.osmdroid.views.overlay.Marker类的典型用法代码示例。如果您正苦于以下问题:Java Marker类的具体用法?Java Marker怎么用?Java Marker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Marker类属于org.osmdroid.views.overlay包,在下文中一共展示了Marker类的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: onActivityCreated
import org.osmdroid.views.overlay.Marker; //导入依赖的package包/类
@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();
}
}
示例5: overrideRouteOnLocationChange
import org.osmdroid.views.overlay.Marker; //导入依赖的package包/类
/**
* 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
}
}
示例6: 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();
}
示例7: createCluster
import org.osmdroid.views.overlay.Marker; //导入依赖的package包/类
private StaticCluster createCluster(Marker m, MapView mapView) {
GeoPoint clusterPosition = m.getPosition();
StaticCluster cluster = new StaticCluster(clusterPosition);
cluster.add(m);
mClonedMarkers.remove(m);
if (mapView.getZoomLevel() > mMaxClusteringZoomLevel) {
//above max level => block clustering:
return cluster;
}
Iterator<Marker> it = mClonedMarkers.iterator();
while (it.hasNext()) {
Marker neighbour = it.next();
int distance = clusterPosition.distanceTo(neighbour.getPosition());
if (distance <= mRadiusInMeters) {
cluster.add(neighbour);
it.remove();
}
}
return cluster;
}
示例8: updateUnitMarker
import org.osmdroid.views.overlay.Marker; //导入依赖的package包/类
public void updateUnitMarker(Device device, Position position) {
try {
Timber.d("UPDATE MARKER: device: $device position: $position");
MarkerWithLabel marker = mMarkers.get(device.getId());
marker.setTitle(device.getName());
if (position.getFixTime() != null) {
marker.setSnippet(position.getFixTime().toString());
}
marker.setIcon(getStatusArrow(device.getStatus()));
marker.setLabelAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM + 2.f);
if (position.getCourse() != null) {
marker.setRotation(position.getCourse());
}
marker.setPosition(new GeoPoint(position.getLatitude(), position.getLongitude()));
} catch (Exception e) {
Timber.w(e);
}
}
示例9: addUnitMarker
import org.osmdroid.views.overlay.Marker; //导入依赖的package包/类
public void addUnitMarker(Device device) {
try {
Timber.tag("MapFragment").d("ADD MARKER: device: $device");
MarkerWithLabel marker = mMarkers.get(device.getId());
if (marker == null) {
marker = new MarkerWithLabel(mMapView);
mRadiusMarkerClusterer.add(marker);
mMarkers.put(device.getId(), marker);
}
marker.setIcon(getStatusArrow(device.getStatus()));
marker.setLabelAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM + 2.f);
marker.setRelatedObject(device);
marker.setTitle(device.getName());
} catch (Exception e) {
Timber.w(e);
}
}
示例10: 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;
}
示例11: 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);
}
}
示例12: onOpen
import org.osmdroid.views.overlay.Marker; //导入依赖的package包/类
@Override
public void onOpen(Object item) {
super.onOpen(item);
Marker marker = (Marker) item;
mSelectedPoi = (GeoPointDto) marker.getRelatedObject();
if (mSelectedPoi != null) {
setText(R.id.bubble_title, mSelectedPoi.getName());
setText(R.id.bubble_description, mSelectedPoi.getDescription());
if (mSelectedPoi.getLink() != null) {
Button btn = (Button) (mView.findViewById(R.id.bubble_moreinfo));
btn.setVisibility(View.VISIBLE);
btn.setOnClickListener(this);
}
// R.id.bubble_image not implemented yet
// R.id.bubble_subdescription not implemented
/* !!!
//8. put thumbnail image in bubble, fetching the thumbnail in background:
if (mSelectedPoi.mThumbnailPath != null){
ImageView imageView = (ImageView)mView.findViewById(R.id.bubble_image);
mSelectedPoi.fetchThumbnailOnThread(imageView);
}
*/
}
}
示例13: createPointOfInterestOverlay
import org.osmdroid.views.overlay.Marker; //导入依赖的package包/类
private RadiusMarkerClusterer createPointOfInterestOverlay(List<Overlay> overlays) {
//10. Marker Clustering
RadiusMarkerClusterer poiMarkers = new RadiusMarkerClustererWithInfo(this) {
@Override
public Marker buildClusterMarker(StaticCluster cluster, MapView mapView) {
Marker result = super.buildClusterMarker(cluster,mapView);
if (cluster.getSize() > 0) {
// show data of the first object in cluster
result.setRelatedObject(cluster.getItem(0).getRelatedObject());
}
return result;
}
};
Drawable clusterIconD = getResources().getDrawable(R.drawable.marker_red_empty);
poiMarkers.setIcon(((BitmapDrawable) clusterIconD).getBitmap());
//end of 10.
//11. Customizing the clusters design
poiMarkers.getTextPaint().setTextSize(12.0f);
poiMarkers.mAnchorV = Marker.ANCHOR_BOTTOM;
poiMarkers.mTextAnchorU = 0.70f;
poiMarkers.mTextAnchorV = 0.27f;
//end of 11.
if (overlays != null) {
overlays.add(poiMarkers);
}
return poiMarkers;
}
示例14: DelayedSetCenterZoom
import org.osmdroid.views.overlay.Marker; //导入依赖的package包/类
/** calculate min/max from all Markers in all overlaysWithMarkers */
public DelayedSetCenterZoom(List<? extends Overlay> overlaysWithMarkers, int zoomLevel) {
if (overlaysWithMarkers.size() > 0) {
Marker first = (Marker) overlaysWithMarkers.get(0);
GeoPoint min = new GeoPoint(first.getPosition().clone());
GeoPoint max = null;
if (overlaysWithMarkers.size() > 1) {
max = min.clone();
for (Overlay item : overlaysWithMarkers) {
getMinMax(min, max, ((Marker) item).getPosition());
}
}
mMin = min;
mMax = max;
}
mZoomLevel = zoomLevel;
}
示例15: LayerMarker
import org.osmdroid.views.overlay.Marker; //导入依赖的package包/类
public LayerMarker(
FragmentMapView mapView,
final OnLayerMarkerClickListener clickListener,
Drawable drawable,
GeoPoint initPosition,
String id) {
super(mapView);
this.setOnClickListener(clickListener);
this.setPosition(initPosition);
this.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
this.setIcon(drawable);
this.id = id;
this.mapView = mapView;
this.minimized = false;
}