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


Java Marker.setSubDescription方法代码示例

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


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

示例1: 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();
}
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:26,代码来源:MapActivity.java

示例2: 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;
}
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:17,代码来源:KmlPoint.java

示例3: addIcons

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
private void addIcons(int count) {
     for (int i = 0; i < count; i++) {
          double random_lon = (Math.random() * 360) - 180;
          double random_lat = (Math.random() * 180) - 90;
          Marker m = new Marker(mMapView);
          m.setPosition(new GeoPoint(random_lat, random_lon));
          int index = (int) (Math.random() * (icons.size()));
          if (index == icons.size()) {
               index--;
          }
          m.setSnippet("A random point");
          m.setSubDescription("location: " + random_lat + "," + random_lon);
          m.setIcon(icons.get(index));
          mMapView.getOverlayManager().add(m);
     }

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

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

示例4: 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;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:25,代码来源:OsmMapShapeConverter.java

示例5: 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();
}
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:35,代码来源:MapActivity.java

示例6: 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;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:38,代码来源:IconPlottingOverlay.java

示例7: onLongPress

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
@Override
public boolean onLongPress(final MotionEvent e, final MapView mapView) {
    if (def != null) {
        GeoPoint pt = (GeoPoint) mapView.getProjection().fromPixels((int) e.getX(), (int) e.getY(), null);

        //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);

        String code = def.getSymbolCode().replace("*", "-");
        //TODO if (!def.isMultiPoint())
        {
            int size = 128;

            SparseArray<String> attr = new SparseArray<>();
            attr.put(MilStdAttributes.PixelSize, size + "");

            ImageInfo ii = MilStdIconRenderer.getInstance().RenderIcon(code, def.getModifiers(), attr);
            Marker m = new Marker(mapView);
            m.setPosition(pt);
            m.setTitle(code);
            m.setSnippet(def.getDescription() + "\n" + def.getHierarchy());
            m.setSubDescription(def.getPath() + "\n" + m.getPosition().getLatitude() + "," + m.getPosition().getLongitude());

            if (ii != null && ii.getImage() != null) {
                BitmapDrawable d = new BitmapDrawable(ii.getImage());
                m.setImage(d);
                m.setIcon(d);

                int centerX = ii.getCenterPoint().x;    //pixel center position
                //calculate what percentage of the center this value is
                float realCenterX = (float) centerX / (float) ii.getImage().getWidth();

                int centerY = ii.getCenterPoint().y;
                float realCenterY = (float) centerY / (float) ii.getImage().getHeight();
                m.setAnchor(realCenterX, realCenterY);


                mapView.getOverlayManager().add(m);
                mapView.invalidate();
            }
        }

        return true;
    }
    return false;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:55,代码来源:MilStdPointPlottingOverlay.java

示例8: onClick

import org.osmdroid.views.overlay.Marker; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.radio_milstd2525b:
        case R.id.radio_milstd2525c:
            if (((RadioButton) v).isChecked()) {
                RendererSettings.getInstance().setSymbologyStandard(RendererSettings.Symbology_2525C);
            } else
                RendererSettings.getInstance().setSymbologyStandard(RendererSettings.Symbology_2525B);
            break;
        case R.id.cancelAddIcon:
            picker.dismiss();
            break;
        case R.id.addIcon:
            //from the menu, user entered code
            String code = symbolCode.getText().toString();
            int size = 128;
            try {
                size = Integer.parseInt(symbolSize.getText().toString());
            } catch (Exception ex) {
            }
            String baseCode = SymbolUtilities.getBasicSymbolID(code);
            SymbolDef def = SymbolDefTable.getInstance().getSymbolDef(baseCode, RendererSettings.getInstance().getSymbologyStandard());

            SparseArray<String> attr = new SparseArray<>();
            attr.put(MilStdAttributes.PixelSize, size + "");

            ImageInfo ii = mir.RenderIcon(code, new SparseArray<String>(), attr);
            Marker m = new Marker(mMapView);
            m.setPosition((GeoPoint) mMapView.getMapCenter());
            m.setTitle(code);
            if (def != null) {
                m.setSubDescription(def.getFullPath());
                m.setSnippet(def.getDescription() + "\n" + def.getHierarchy());
            }
            Drawable d = new BitmapDrawable(ii.getImage());
            m.setImage(d);
            m.setIcon(d);
            int centerX = ii.getCenterPoint().x;    //pixel center position
            //calculate what percentage of the center this value is
            float realCenterX = (float) centerX / (float) ii.getImage().getWidth();

            int centerY = ii.getCenterPoint().y;
            float realCenterY = (float) centerY / (float) ii.getImage().getHeight();
            m.setAnchor(realCenterX, realCenterY);
            mMapView.getOverlayManager().add(m);
            mMapView.invalidate();
            picker.dismiss();

            //TODO store the symbol code and size as an android preference
            SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(getContext()).edit();
            edit.putString("MILSTDCODE", code);
            RendererSettings.getInstance().setDefaultPixelSize(size);
            edit.putInt("MILSTDSIZE", size);
            edit.commit();

            break;
        case R.id.enablePanning:
            enablePanning();

            break;
        case R.id.enablePainting:
            enablePainting();
            break;
    }
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:67,代码来源:Plotter.java


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