本文整理汇总了Java中org.osmdroid.views.overlay.ItemizedIconOverlay.OnItemGestureListener方法的典型用法代码示例。如果您正苦于以下问题:Java ItemizedIconOverlay.OnItemGestureListener方法的具体用法?Java ItemizedIconOverlay.OnItemGestureListener怎么用?Java ItemizedIconOverlay.OnItemGestureListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osmdroid.views.overlay.ItemizedIconOverlay
的用法示例。
在下文中一共展示了ItemizedIconOverlay.OnItemGestureListener方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPopup
import org.osmdroid.views.overlay.ItemizedIconOverlay; //导入方法依赖的package包/类
private void setPopup(MapView mapv, ParkingSpot spot, GeoPoint point){
final MapView map = mapv;
if(popupOverlay != null) {
map.getOverlays().remove(popupOverlay);
}
OverlayItem popup = new OverlayItem(spot.name(), spot.state(), point);
String val;
switch (spot.state()){
case "closed":
val = getString(R.string.closed);
break;
case "nodata":
val = getString(R.string.nodata);
break;
default:
val = String.valueOf(spot.free()) + " " + getString(R.string.of) + " " + String.valueOf(spot.count());
break;
}
SlotPopup marker = new SlotPopup(spot.name(), val, this);
popup.setMarker(marker.getBitmapDrawable());
ArrayList<OverlayItem> popupList = new ArrayList<>();
popupList.add(popup);
popupOverlay = new ItemizedIconOverlay<>(this, popupList, new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
@Override
public boolean onItemSingleTapUp(int index, OverlayItem item) {
map.getOverlays().remove(popupOverlay);
return false;
}
@Override
public boolean onItemLongPress(int index, OverlayItem item) {
return false;
}
});
map.getOverlays().add(popupOverlay);
}
示例2: addMarker
import org.osmdroid.views.overlay.ItemizedIconOverlay; //导入方法依赖的package包/类
@Override
public void addMarker(final Marker aMarker) {
if (mItemizedOverlay == null) {
// XXX this is a bit cumbersome. Maybe we should just do a simple ItemizedIconOverlay with null listener
mItemizedOverlay = new ItemizedOverlayWithFocus<OverlayItem>(new ArrayList<OverlayItem>(), new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
@Override
public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
return false;
}
@Override
public boolean onItemLongPress(final int index, final OverlayItem item) {
return false;
}
},this.mMapView.getContext());
mItemizedOverlay.setFocusItemsOnTap(true);
mMapView.getOverlays().add(mItemizedOverlay);
}
final OverlayItem item = new OverlayItem(aMarker.title, aMarker.snippet, new GeoPoint(aMarker.latitude, aMarker.longitude));
if (aMarker.bitmap != null) {
item.setMarker(new BitmapDrawable(mMapView.getResources(), aMarker.bitmap));
} else {
if (aMarker.icon != 0) {
item.setMarker(mMapView.getResources().getDrawable(aMarker.icon));
}
}
if (aMarker.anchor == Marker.Anchor.CENTER) {
item.setMarkerHotspot(OverlayItem.HotspotPlace.CENTER);
}
mItemizedOverlay.addItem(item);
}
示例3: config
import org.osmdroid.views.overlay.ItemizedIconOverlay; //导入方法依赖的package包/类
private void config(){
Drawable onlineMarker=getResources().getDrawable(R.mipmap.ic_radiotower_green);
Drawable offlineMarker=getResources().getDrawable(R.mipmap.ic_radiotower_red);
int backgroundColor=Color.parseColor("#ffffff");
ewOverlay=new ItemizedOverlayWithFocus<>(onlineWide,onlineMarker,onlineMarker, backgroundColor,
new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
@Override
public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
//do something
return true;
}
@Override
public boolean onItemLongPress(final int index, final OverlayItem item) {
return false;
}
},getContext());
dwOverlay=new ItemizedOverlayWithFocus<>(offlineWide,offlineMarker,offlineMarker, backgroundColor,
new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
@Override
public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
//do something
return true;
}
@Override
public boolean onItemLongPress(final int index, final OverlayItem item) {
return false;
}
},getContext());
epOverlay=new ItemizedOverlayWithFocus<>(onlinePers,onlineMarker,onlineMarker, backgroundColor,
new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
@Override
public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
//do something
return true;
}
@Override
public boolean onItemLongPress(final int index, final OverlayItem item) {
return false;
}
},getContext());
dpOverlay=new ItemizedOverlayWithFocus<>(offlinePers,offlineMarker,offlineMarker, backgroundColor,
new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
@Override
public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
//do something
return true;
}
@Override
public boolean onItemLongPress(final int index, final OverlayItem item) {
return false;
}
},getContext());
dwOverlay.setEnabled(false);
epOverlay.setEnabled(false);
dpOverlay.setEnabled(false);
ewOverlay.setFocusItemsOnTap(true);
ItemizedOverlayWithFocus[] ovList={ewOverlay,dwOverlay,epOverlay,dpOverlay};
fo = new FolderOverlay();
for(ItemizedOverlayWithFocus t : ovList){
//t.setDescriptionBoxCornerWidth(32);
//t.setDescriptionBoxPadding(6);
//t.setDescriptionMaxWidth(200);
fo.add(t);
}
map.getOverlays().add(fo);
ewOverlay.setFocusItemsOnTap(true);
}
示例4: drawMarkers
import org.osmdroid.views.overlay.ItemizedIconOverlay; //导入方法依赖的package包/类
private void drawMarkers(){
/*Add markers on the map*/
final ItemizedOverlayWithFocus<OverlayItem> overlay;
final ArrayList<OverlayItem> items = new ArrayList<OverlayItem>();
final POI belfort = new POI();
belfort.id = -1; //used to disable the clickhandler for this poi
belfort.ENG_name = "Belfry";
belfort.ENG_description = "";
belfort.NL_name = "Belfort";
belfort.NL_description = "";
belfort.lat = DataManager.BELFORT_LAT +"";
belfort.lon = DataManager.BELFORT_LON +"";
final OverlayItem overlayItem = getOverlayItemFromPOI(belfort,getResources().getDrawable(R.drawable.castle));
items.add(overlayItem);
for(POI poi : RouteManager.getInstance().getWaypoints()){
final OverlayItem item = getOverlayItemFromPOI(poi,null);
items.add(item);
}
overlay = new ItemizedOverlayWithFocus<OverlayItem>(getActivity().getApplicationContext(), items,
new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
@Override
public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
final ArtoriaOverlayItem overlayItem = (ArtoriaOverlayItem)item;
final POI selectedItem = ((ArtoriaOverlayItem) item).poi;
if(selectedItem.id != -1) {
Intent i = MonumentDetailActivity.newIntent(getActivity(), selectedItem.id, false);
startActivity(i);
}
return true; // We 'handled' this event.
}
@Override
public boolean onItemLongPress(final int index, final OverlayItem item) {
return false;
}
});
mapView.getOverlays().add(overlay);
mapView.invalidate();
}
示例5: addOverlays
import org.osmdroid.views.overlay.ItemizedIconOverlay; //导入方法依赖的package包/类
@Override
protected void addOverlays() {
super.addOverlays();
final Context context = getActivity();
icons.add(getResources().getDrawable(org.osmdroid.R.drawable.sfgpuci));
icons.add(getResources().getDrawable(org.osmdroid.R.drawable.shgpuci));
icons.add(getResources().getDrawable(org.osmdroid.R.drawable.sngpuci));
icons.add(getResources().getDrawable(org.osmdroid.R.drawable.sugpuci));
/* Itemized Overlay */
{
/* OnTapListener for the Markers, shows a simple Toast. */
itemOverlay = new ItemizedOverlayWithFocus<>(new ArrayList<OverlayItem>(),
new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
@Override
public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
Toast.makeText(
context,
"Item '" + item.getTitle() + "' (index=" + index
+ ") got single tapped up", Toast.LENGTH_LONG).show();
return true;
}
@Override
public boolean onItemLongPress(final int index, final OverlayItem item) {
Toast.makeText(
context,
"Item '" + item.getTitle() + "' (index=" + index
+ ") got long pressed", Toast.LENGTH_LONG).show();
return false;
}
}, context);
itemOverlay.setFocusItemsOnTap(true);
itemOverlay.setFocusedItem(0);
//generates 50 randomized points
addIcons(50);
mMapView.getOverlays().add(itemOverlay);
mRotationGestureOverlay = new RotationGestureOverlay(mMapView);
mRotationGestureOverlay.setEnabled(false);
mMapView.getOverlays().add(mRotationGestureOverlay);
}
/* MiniMap */
{
// MinimapOverlay miniMapOverlay = new MinimapOverlay(context,
// mMapView.getTileRequestCompleteHandler());
// mMapView.getOverlays().add(miniMapOverlay);
}
// Zoom and center on the focused item.
mMapView.getController().setZoom(3);
IGeoPoint geoPoint = itemOverlay.getFocusedItem().getPoint();
mMapView.getController().animateTo(geoPoint);
setHasOptionsMenu(true);
Toast.makeText(context, "Icon selection and location are random!", Toast.LENGTH_SHORT).show();
}
示例6: addOverlays
import org.osmdroid.views.overlay.ItemizedIconOverlay; //导入方法依赖的package包/类
@Override
protected void addOverlays() {
super.addOverlays();
final Context context = getActivity();
/* Itemized Overlay */
{
/* Create a static ItemizedOverlay showing some Markers on various cities. */
final ArrayList<OverlayItem> items = new ArrayList<>();
for (int i=0; i < 500; i++){
double random_lon=(Math.random() * 360) -180;
double random_lat = (Math.random() * 180) - 90;
items.add(new OverlayItem("A random point", "SampleDescription", new GeoPoint(random_lat,
random_lon)));
}
items.add(new OverlayItem("Berlin", "This is a relatively short SampleDescription.",
new GeoPoint(52518333, 13408333))); // Berlin
items.add(new OverlayItem(
"Washington",
"This SampleDescription is a pretty long one. Almost as long as a the great wall in china.",
new GeoPoint(38895000, -77036667))); // Washington
items.add(new OverlayItem("San Francisco", "SampleDescription", new GeoPoint(37779300,
-122419200))); // San Francisco
/* OnTapListener for the Markers, shows a simple Toast. */
iconOverlay = new ItemizedOverlayWithFocus<>(items,
new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
@Override
public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
Toast.makeText(
context,
"Item '" + item.getTitle() + "' (index=" + index
+ ") got single tapped up", Toast.LENGTH_LONG).show();
return true;
}
@Override
public boolean onItemLongPress(final int index, final OverlayItem item) {
Toast.makeText(
context,
"Item '" + item.getTitle() + "' (index=" + index
+ ") got long pressed", Toast.LENGTH_LONG).show();
return false;
}
}, context);
iconOverlay.setFocusItemsOnTap(true);
iconOverlay.setFocusedItem(0);
mMapView.getOverlays().add(iconOverlay);
mRotationGestureOverlay = new RotationGestureOverlay(mMapView);
mRotationGestureOverlay.setEnabled(false);
mMapView.getOverlays().add(mRotationGestureOverlay);
}
/* MiniMap */
{
//MinimapOverlay miniMapOverlay = new MinimapOverlay(context,
// mMapView.getTileRequestCompleteHandler());
//mMapView.getOverlays().add(miniMapOverlay);
}
// Zoom and center on the focused item.
mMapView.getController().setZoom(5);
IGeoPoint geoPoint = iconOverlay.getFocusedItem().getPoint();
mMapView.getController().animateTo(geoPoint);
setHasOptionsMenu(false);
}
示例7: addOverlays
import org.osmdroid.views.overlay.ItemizedIconOverlay; //导入方法依赖的package包/类
@Override
protected void addOverlays() {
super.addOverlays();
final Context context = getActivity();
/* Itemized Overlay */
{
/* Create a static ItemizedOverlay showing some Markers on various cities. */
final ArrayList<OverlayItem> items = new ArrayList<>();
items.add(new OverlayItem("Hannover", "Tiny SampleDescription", new GeoPoint(52370816,
9735936))); // Hannover
items.add(new OverlayItem("Berlin", "This is a relatively short SampleDescription.",
new GeoPoint(52518333, 13408333))); // Berlin
items.add(new OverlayItem(
"Washington",
"This SampleDescription is a pretty long one. Almost as long as a the great wall in china.",
new GeoPoint(38895000, -77036667))); // Washington
items.add(new OverlayItem("San Francisco", "SampleDescription", new GeoPoint(37779300,
-122419200))); // San Francisco
/* OnTapListener for the Markers, shows a simple Toast. */
mMyLocationOverlay = new ItemizedOverlayWithFocus<>(items,
new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
@Override
public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
Toast.makeText(
context,
"Item '" + item.getTitle() + "' (index=" + index
+ ") got single tapped up", Toast.LENGTH_LONG).show();
return true;
}
@Override
public boolean onItemLongPress(final int index, final OverlayItem item) {
Toast.makeText(
context,
"Item '" + item.getTitle() + "' (index=" + index
+ ") got long pressed", Toast.LENGTH_LONG).show();
return false;
}
}, context);
mMyLocationOverlay.setFocusItemsOnTap(true);
mMyLocationOverlay.setFocusedItem(0);
//https://github.com/osmdroid/osmdroid/issues/317
//you can override the drawing characteristics with this
mMyLocationOverlay.setMarkerBackgroundColor(Color.BLUE);
mMyLocationOverlay.setMarkerTitleForegroundColor(Color.WHITE);
mMyLocationOverlay.setMarkerDescriptionForegroundColor(Color.WHITE);
mMyLocationOverlay.setDescriptionBoxPadding(15);
mMapView.getOverlays().add(mMyLocationOverlay);
mRotationGestureOverlay = new RotationGestureOverlay(mMapView);
mRotationGestureOverlay.setEnabled(false);
mMapView.getOverlays().add(mRotationGestureOverlay);
}
/* MiniMap */
{
MinimapOverlay miniMapOverlay = new MinimapOverlay(context,
mMapView.getTileRequestCompleteHandler());
mMapView.getOverlays().add(miniMapOverlay);
}
// Zoom and center on the focused item.
mMapView.getController().setZoom(5);
IGeoPoint geoPoint = mMyLocationOverlay.getFocusedItem().getPoint();
mMapView.getController().animateTo(geoPoint);
setHasOptionsMenu(true);
}