当前位置: 首页>>代码示例>>Java>>正文


Java OverlayItem.setMarker方法代码示例

本文整理汇总了Java中org.osmdroid.views.overlay.OverlayItem.setMarker方法的典型用法代码示例。如果您正苦于以下问题:Java OverlayItem.setMarker方法的具体用法?Java OverlayItem.setMarker怎么用?Java OverlayItem.setMarker使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.osmdroid.views.overlay.OverlayItem的用法示例。


在下文中一共展示了OverlayItem.setMarker方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateMarker

import org.osmdroid.views.overlay.OverlayItem; //导入方法依赖的package包/类
private void updateMarker(GeoPoint pt, boolean center) {
    final String markerTitle = "Fake Location", markerDescription = "You seem to be here.";

    // add marker for new location
    markerOverlay = new OverlayItem(markerTitle, markerDescription, pt);
    markerOverlay.setMarker(myMarker);

    // replace marker. there's no method for updating it directly
    markersOverlay.removeAllItems();
    markersOverlay.addItem(markerOverlay);

    // pan map?
    if (center) {
        mapController.setCenter(pt);
    } else {
        // redraw map to show new marker
        findViewById(R.id.map).invalidate();
    }
}
 
开发者ID:spezifisch,项目名称:ThreeStepsAhead,代码行数:20,代码来源:MainActivity.java

示例2: run

import org.osmdroid.views.overlay.OverlayItem; //导入方法依赖的package包/类
public void run()
{
    try {
        JSONArray jr3 = Utils.getJSON("https://applications002.brest-metropole.fr/WIPOD01/Transport.svc/getGeolocatedVehiclesPosition?format=json&route_id=" + product + "&trip_headsign=" + terminus.replace(" ", "%20"));
        Resources res = getResources();
        overlayItemArray.clear();
        mMap.getOverlays().clear();
        mMap.invalidate();
        for (int i = 0; i < jr3.length(); i++) {
            JSONObject object = (JSONObject) jr3.getJSONObject(i);
            OverlayItem overlayItem = new OverlayItem("0, 0", "0, 0", new GeoPoint(Double.valueOf(object.getString("Lat")), Double.valueOf(object.getDouble("Lon"))));
            overlayItem.setMarker(res.getDrawable(R.drawable.icone_bus));
            overlayItemArray.add(overlayItem);
        }
        ItemizedIconOverlay<OverlayItem> anotherItemizedIconOverlay = new ItemizedIconOverlay<OverlayItem>(getActivity(), overlayItemArray, null);
        mMap.getOverlays().add(roadOverlay);
        mMap.getOverlays().add(anotherItemizedIconOverlay);
    } catch (Exception ex) { ex.getMessage(); }

    mHandler.postDelayed(m_Runnable, 60000);
}
 
开发者ID:Darkitty,项目名称:BTB,代码行数:22,代码来源:Fragment_traceLine.java

示例3: addIcons

import org.osmdroid.views.overlay.OverlayItem; //导入方法依赖的package包/类
private void addIcons(int count) {
      /* Create a static ItemizedOverlay showing some Markers on various cities. */
     final ArrayList<OverlayItem> items = new ArrayList<>();
     for (int i = 0; i < count; i++) {
          double random_lon = (Math.random() * 360) - 180;
          double random_lat = (Math.random() * 180) - 90;
          overlayItem = new OverlayItem("A random point", "SampleDescription", new GeoPoint(random_lat,
                  random_lon));
          int index = (int) (Math.random() * (icons.size()));
          if (index == icons.size()) {
               index--;
          }
          overlayItem.setMarker(icons.get(index));
          items.add(overlayItem);

     }
     itemOverlay.addItems(items);
     mMapView.invalidate();
     Toast.makeText(getActivity(), count + " icons added! Current size: " + itemOverlay.size(), Toast.LENGTH_SHORT).show();

}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:22,代码来源:SampleMilitaryIconsItemizedIcons.java

示例4: setLocation

import org.osmdroid.views.overlay.OverlayItem; //导入方法依赖的package包/类
public void setLocation(Location location) {
    IMapController mapController = mMapView.getController();
    mapController.setZoom(16);
    GeoPoint gPoint = new GeoPoint(location.getLatCoord(), location.getLongCoord());
    mapController.setCenter(gPoint);

    mMarkerItem = new OverlayItem(location.getName(), location.getVegan().toString(), gPoint);
    Drawable marker = getResources().getDrawable(R.mipmap.ic_map_pin_red);
    mMarkerItem.setMarker(marker);
    mLocationOverlay.addItem(mMarkerItem);
}
 
开发者ID:Berlin-Vegan,项目名称:berlin-vegan-guide,代码行数:12,代码来源:LocationMapFragment.java

示例5: markChosenPicture

import org.osmdroid.views.overlay.OverlayItem; //导入方法依赖的package包/类
private void markChosenPicture(int pic) {
	for (int i = 0; i < pics.size(); i++) {
		if (oItem.size() > 0) {
			OverlayItem o = oItem.get(i);

			if (i == pic)
				o.setMarker(res.getDrawable(R.drawable.selected_picture_pin));
			else
				o.setMarker(res.getDrawable(R.drawable.picture_pin));
		}
	}
	mapView.postInvalidate();
}
 
开发者ID:scintero,项目名称:moveon,代码行数:14,代码来源:Summary1.java

示例6: setOverlayLoc

import org.osmdroid.views.overlay.OverlayItem; //导入方法依赖的package包/类
private void setOverlayLoc(Location overlayloc) {
	GeoPoint overlocGeoPoint = new GeoPoint(overlayloc);
	// ---
	overlayItemArray.clear();

	OverlayItem newMyLocationItem = new OverlayItem("My Location",
			"My Location", overlocGeoPoint);
	newMyLocationItem.setMarker(this.getResources().getDrawable(
			R.drawable.ic_menu_mylocation));
	overlayItemArray.add(newMyLocationItem);
	new LongRunningGetIO().execute();
	// ---
}
 
开发者ID:TareeqH,项目名称:GeoWork,代码行数:14,代码来源:myApp.java

示例7: onPostExecute

import org.osmdroid.views.overlay.OverlayItem; //导入方法依赖的package包/类
protected void onPostExecute(String results) {
	if (results != null) {
		Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd")
				.create();
		responseWs = gson.fromJson(results, ResponseWs.class);
		if (responseWs != null) {
			for (Restaurant restaurant : responseWs.getRestaurants()) {
				OverlayItem item = new OverlayItem(""
						+ restaurant.getId(), restaurant.getName(),
						restaurant.getAddress(), new GeoPoint(
								restaurant.getLatitude(),
								restaurant.getLongitude()));
				Drawable icon;
				switch (restaurant.getRate()) {
				case "V":
					icon = context.getResources().getDrawable(
							R.drawable.b_marker);
					break;
				case "R":
					icon = context.getResources().getDrawable(
							R.drawable.r_marker);
					break;
				default:
					continue;
				}
				item.setMarker(icon);
				overlayItemArray.add(item);
			}
			ItemizedIconOverlay<OverlayItem> anotherItemizedIconOverlay = new ItemizedIconOverlay<OverlayItem>(
					context, overlayItemArray, myOnItemGestureListener);
			myOpenMapView.getOverlays().add(anotherItemizedIconOverlay);
			myOpenMapView.invalidate();
		}

	}
}
 
开发者ID:TareeqH,项目名称:GeoWork,代码行数:37,代码来源:myApp.java

示例8: onPostExecute

import org.osmdroid.views.overlay.OverlayItem; //导入方法依赖的package包/类
protected void onPostExecute(String results) {
	if (results != null) {
		Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd")
				.create();
		responseWs = gson.fromJson(results, ResponseWs.class);
		if (responseWs != null) {
			for (Restaurant restaurant : responseWs.getRestaurants()) {
				OverlayItem item = new OverlayItem(""
						+ restaurant.getId(), restaurant.getName(),
						restaurant.getAddress(), new GeoPoint(
								restaurant.getLatitude(),
								restaurant.getLongitude()));
				Drawable icon;
				switch (restaurant.getRate()) {
				case "V":
					icon = context.getResources().getDrawable(
							R.drawable.b_marker);
					break;
				case "R":
					icon = context.getResources().getDrawable(
							R.drawable.r_marker);
					break;
				default:
					continue;
				}
				item.setMarker(icon);
				anotherOverlayItemArray.add(item);
			}
			ItemizedIconOverlay<OverlayItem> anotherItemizedIconOverlay = new ItemizedIconOverlay<OverlayItem>(
					context, anotherOverlayItemArray,
					myOnItemGestureListener);
			myOpenMapView.getOverlays().add(anotherItemizedIconOverlay);
			myOpenMapView.invalidate();
		}

	}
}
 
开发者ID:TareeqH,项目名称:GeoWork,代码行数:38,代码来源:AndroidOpenStreetMapViewActivity.java

示例9: setupTrackToView

import org.osmdroid.views.overlay.OverlayItem; //导入方法依赖的package包/类
private void setupTrackToView() {


        // simulate flight Track
        if (flightLog.size() == 0)
            simulateTrack();

        // Info Table
        gpsData = (ListView) findViewById(R.id.fm_table);
        gpsListAdapterView = new GpsListAdapter(this);
        gpsData.setAdapter(gpsListAdapterView);
        for (int j = 0; j < flightLog.size(); j++)
            gpsListAdapterView.add(flightLog.get(j));

        gpsData.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> arg0, View arg1,
                                    int position, long arg3) {

                map.getController().setCenter(
                        new GeoPoint(flightLog.get(position).getLatitude(),
                                flightLog.get(position).getLongitude()));
            }

            public void onNothingSelected(AdapterView parentView) {

            }
        });

        double speedMax = 0.;
        double heightMin = 0., heightMax = 0.;
        for (int k = 0; k < flightLog.size(); k++) {
            double speed = flightLog.get(k).getSpeedValue(SPEED.ms);
            if (speedMax < speed)
                speedMax = speed;

            double height = flightLog.get(k).getAltitude();
            if (heightMin > height)
                heightMin = height;
            if (heightMax < height)
                heightMax = height;
        }

        StringBuilder flightInfo = new StringBuilder();
        flightInfo.append("max. Speed " + speedMax + " m/s\n");
        flightInfo.append("min. Height " + heightMin + ", max. Height "
                + heightMax);
        tv_info.setText(flightInfo.toString());

        // Overlay Path
        PathOverlay myPath = new PathOverlay(Color.RED, this);
        for (int i = 0; i < flightLog.size(); i++) {
            myPath.addPoint(new GeoPoint(flightLog.get(i).getLatitude(),
                    flightLog.get(i).getLongitude()));
        }
        map.getOverlays().add(myPath);

        // Special Points
        map.getController().setCenter(getCenterPoint());

        resourceProxy = new DefaultResourceProxyImpl(getApplicationContext());
        poi = new ArrayList<>();

        OverlayItem start = new OverlayItem("Start", "Position",
                new GeoPoint(flightLog.get(0).getLatitude(), flightLog.get(0)
                        .getLongitude()));
        Drawable blkMarker = getResources().getDrawable(
                R.drawable.map_blk_marker_small);
        start.setMarker(blkMarker);
        poi.add(start);

        OverlayItem end = new OverlayItem("End", "Position", new GeoPoint(
                flightLog.get(flightLog.size() - 1).getLatitude(), flightLog
                .get(flightLog.size() - 1).getLongitude()));
        Drawable blueMarker = getResources().getDrawable(
                R.drawable.map_blue_marker_small);
        end.setMarker(blueMarker);
        poi.add(end);
        POIItemizedOverlay overlay = new POIItemizedOverlay(this, poi);
        map.getOverlays().add(overlay);
    }
 
开发者ID:fabianhu,项目名称:FCM-Android,代码行数:81,代码来源:FlightMap.java

示例10: createItemList

import org.osmdroid.views.overlay.OverlayItem; //导入方法依赖的package包/类
private ArrayList<OverlayItem> createItemList(ArrayList<ParkingSpot> spotlist){
    ArrayList<OverlayItem> itemList = new ArrayList<>();
    for(ParkingSpot spot : spotlist){
        String desc = "";
        SpotIcon marker = new SpotIcon(spot, this);
        switch (spot.state()){
            case "closed":
                desc = getString(R.string.closed);
                break;
            case "nodata":
                desc = getString(R.string.nodata);
                break;
            default:
                desc = String.valueOf(spot.free()) + " " + getString(R.string.of)  + " " + String.valueOf(spot.count());
                break;
        }
        try {
            OverlayItem olItem = new OverlayItem(spot.name(), desc, new GeoPoint(spot.location().getLatitude(), spot.location().getLongitude()));
            olItem.setMarker(marker.getBitmapDrawable());
            olItem.setMarkerHotspot(OverlayItem.HotspotPlace.CENTER);
            itemList.add(olItem);
        }catch (NullPointerException e){
            e.printStackTrace();
        }
    }
    return itemList;
}
 
开发者ID:jklmnn,项目名称:ParkenDD,代码行数:28,代码来源:MapActivity.java

示例11: setPopup

import org.osmdroid.views.overlay.OverlayItem; //导入方法依赖的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);
}
 
开发者ID:jklmnn,项目名称:ParkenDD,代码行数:37,代码来源:MapActivity.java

示例12: addMarker

import org.osmdroid.views.overlay.OverlayItem; //导入方法依赖的package包/类
private OverlayItem addMarker(final IGeoPoint point, final String label, final Drawable icon)
{
  if(point == null)
    return null;
  controller().pushUndo(this);
  final OverlayItem marker = new OverlayItem(label, label, new GeoPoint(point.getLatitudeE6(), point.getLongitudeE6()));
  marker.setMarker(icon);
  marker.setMarkerHotspot(OverlayItem.HotspotPlace.BOTTOM_CENTER);
  return marker;
}
 
开发者ID:MobileAppCodes,项目名称:CycleStreets-Android-app-,代码行数:11,代码来源:TapToRouteOverlay.java

示例13: addMarker

import org.osmdroid.views.overlay.OverlayItem; //导入方法依赖的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);
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:32,代码来源:OsmdroidMapWrapper.java

示例14: addIcons

import org.osmdroid.views.overlay.OverlayItem; //导入方法依赖的package包/类
private void addIcons() {
	mItems = new ArrayList<OverlayItem>();
	OverlayItem olItem = new OverlayItem("Here", "SampleDescription", mCurrentPoint);
	Drawable newMarker = this.getResources().getDrawable(R.drawable.ic_launcher);
	olItem.setMarker(newMarker);
	mItems.add(olItem);
	mResourceProxy = new DefaultResourceProxyImpl(this);
	//mMyLocationOverlay = new ItemizedIconOverlay<OverlayItem>(mItems, newMarker, new Glistener(), mResourceProxy);
	mMyItimizedLocationOverlay = new ItemizedIconOverlay<OverlayItem>(mItems, newMarker, null, mResourceProxy );
       mMapView.getOverlays().clear();
       mMapView.getOverlays().add(mMyItimizedLocationOverlay);

}
 
开发者ID:alain75007,项目名称:androidschool,代码行数:14,代码来源:GameActivity.java

示例15: refreshLocationsOnMap

import org.osmdroid.views.overlay.OverlayItem; //导入方法依赖的package包/类
public void refreshLocationsOnMap(){
    map.getOverlays().clear();
    map.invalidate();

    placeMarkers.clear();
    allPlaces = Place.getAll();


    for(Place place: allPlaces){
        OverlayItem placeOverlayItem = new OverlayItem(
                place.getAddress(), place.getDescription(), new GeoPoint(place.getLatitude(), place.getLongitude()));
        Drawable myCurrentLocationMarker = this.getResources().getDrawable(R.drawable.marker_cloud);
        placeOverlayItem.setMarker(myCurrentLocationMarker);
        placeMarkers.add(placeOverlayItem);
    }


    // add my current location overlay
    if(currentLocation != null){
        OverlayItem myLocationOverlayItem = new OverlayItem("Here", "Current location",
                new GeoPoint(currentLocation.getLatitude(), currentLocation.getLongitude()));
        myLocationOverlayItem.setMarkerHotspot(OverlayItem.HotspotPlace.CENTER);
        placeMarkers.add(myLocationOverlayItem);
    }


    ItemizedIconOverlay<OverlayItem> anotherItemizedIconOverlay
            = new ItemizedIconOverlay<OverlayItem>(
            getActivity(), placeMarkers, null);
    map.getOverlays().add(anotherItemizedIconOverlay);


    ScaleBarOverlay myScaleBarOverlay = new ScaleBarOverlay(map);
    map.getOverlays().add(myScaleBarOverlay);

    MyLocationNewOverlay mLocationOverlay = new MyLocationNewOverlay(new GpsMyLocationProvider(getActivity()), map);
    map.getOverlays().add(mLocationOverlay);

    CompassOverlay mCompassOverlay = new CompassOverlay(getActivity(), new InternalCompassOrientationProvider(getActivity()), map);
    map.getOverlays().add(mCompassOverlay);

    /*RotationGestureOverlay mRotationGestureOverlay = new RotationGestureOverlay(getActivity(), map);
    mRotationGestureOverlay.setEnabled(true);
    map.setMultiTouchControls(true);
    map.getOverlays().add(mRotationGestureOverlay);*/


    setBoundingBox();

}
 
开发者ID:hamzux,项目名称:cosi,代码行数:51,代码来源:PlacesFragment.java


注:本文中的org.osmdroid.views.overlay.OverlayItem.setMarker方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。