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


Java MapView.getContext方法代码示例

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


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

示例1: createMarkersCluster

import org.osmdroid.views.MapView; //导入方法依赖的package包/类
public GridMarkerClusterer createMarkersCluster(@NonNull MapView mapView,
                                                @NonNull ResourceProxy resourceProxy,
                                                @NonNull Marker.OnMarkerClickListener listener) {
    final GridMarkerClusterer gridMarkerClusterer = new GridMarkerClusterer(mapView.getContext());
    gridMarkerClusterer.setGridSize(MapsConfig.GRID_SIZE);

    final Resources resources = mapView.getContext().getResources();
    if (resources == null) throw new RuntimeException("Cannot get resources from context");
    final BitmapDrawable clusterDrawable = ((BitmapDrawable) resources.getDrawable(R.drawable.image_map_cluster));
    if (clusterDrawable == null) {
        throw new RuntimeException("Cannot get Drawable from resource");
    }
    gridMarkerClusterer.setIcon(clusterDrawable.getBitmap());

    for (CustomMarkerModel model : getCustomMarkerModels()) {
        gridMarkerClusterer.add(new CustomMarker(model, mapView, resources, resourceProxy, listener));
    }

    return gridMarkerClusterer;
}
 
开发者ID:yuviii,项目名称:OfflineMap,代码行数:21,代码来源:AbstractMap.java

示例2: createMarkersCluster

import org.osmdroid.views.MapView; //导入方法依赖的package包/类
public GridMarkerClusterer createMarkersCluster(@NonNull MapView mapView,
                                                  @NonNull ResourceProxy resourceProxy,
                                                  @NonNull Marker.OnMarkerClickListener listener) {
    final GridMarkerClusterer gridMarkerClusterer = new GridMarkerClusterer(mapView.getContext());
    gridMarkerClusterer.setGridSize(MapsConfig.GRID_SIZE);

    final Resources resources = mapView.getContext().getResources();
    if (resources == null) throw new RuntimeException("Cannot get resources from context");
    final BitmapDrawable clusterDrawable = ((BitmapDrawable) resources.getDrawable(R.drawable.image_map_cluster));
    if (clusterDrawable == null) {
        throw new RuntimeException("Cannot get Drawable from resource");
    }
    gridMarkerClusterer.setIcon(clusterDrawable.getBitmap());

    for (CustomMarkerModel model : getCustomMarkerModels()) {
        gridMarkerClusterer.add(new CustomMarker(model, mapView, resources, resourceProxy, listener));
    }

    return gridMarkerClusterer;
}
 
开发者ID:lassana,项目名称:offline-routing-sample,代码行数:21,代码来源:AbstractMap.java

示例3: applyDefaultStyling

import org.osmdroid.views.MapView; //导入方法依赖的package包/类
public void applyDefaultStyling(Polyline lineStringOverlay, Style defaultStyle, KmlPlacemark kmlPlacemark,
		KmlDocument kmlDocument, MapView map){
	Context context = map.getContext();
	Style style = kmlDocument.getStyle(kmlPlacemark.mStyle);
	if (style != null){
		lineStringOverlay.setColor(style.getOutlinePaint().getColor());
		lineStringOverlay.setWidth(style.getOutlinePaint().getStrokeWidth());
	} else if (defaultStyle!=null && defaultStyle.mLineStyle!=null){ 
		lineStringOverlay.setColor(defaultStyle.getOutlinePaint().getColor());
		lineStringOverlay.setWidth(defaultStyle.getOutlinePaint().getStrokeWidth());
	}
	if ((kmlPlacemark.mName!=null && !"".equals(kmlPlacemark.mName)) 
			|| (kmlPlacemark.mDescription!=null && !"".equals(kmlPlacemark.mDescription))
			|| (lineStringOverlay.getSubDescription()!=null && !"".equals(lineStringOverlay.getSubDescription()))
			){
		if (mDefaultLayoutResId == BonusPackHelper.UNDEFINED_RES_ID){
			String packageName = context.getPackageName();
			mDefaultLayoutResId = context.getResources().getIdentifier("layout/bonuspack_bubble", null, packageName);
		}
		lineStringOverlay.setInfoWindow(new BasicInfoWindow(mDefaultLayoutResId, map));
	}
	lineStringOverlay.setEnabled(kmlPlacemark.mVisibility);
}
 
开发者ID:jeffallen,项目名称:MarshrutMe,代码行数:24,代码来源:KmlLineString.java

示例4: buildOverlay

import org.osmdroid.views.MapView; //导入方法依赖的package包/类
/** Build the corresponding Polyline overlay */	
@Override public Overlay buildOverlay(MapView map, Style defaultStyle, Styler styler, KmlPlacemark kmlPlacemark, 
		KmlDocument kmlDocument){
	Context context = map.getContext();
	Polyline lineStringOverlay = new Polyline(context);
	lineStringOverlay.setPoints(mCoordinates);
	lineStringOverlay.setTitle(kmlPlacemark.mName);
	lineStringOverlay.setSnippet(kmlPlacemark.mDescription);
	lineStringOverlay.setSubDescription(kmlPlacemark.getExtendedDataAsText());
	if (styler != null)
		styler.onLineString(lineStringOverlay, kmlPlacemark, this);
	else {
		applyDefaultStyling(lineStringOverlay, defaultStyle, kmlPlacemark, kmlDocument, map);
	}
	return lineStringOverlay;
}
 
开发者ID:jeffallen,项目名称:MarshrutMe,代码行数:17,代码来源:KmlLineString.java

示例5: buildOverlay

import org.osmdroid.views.MapView; //导入方法依赖的package包/类
/** Build the corresponding Polygon overlay */
@Override public Overlay buildOverlay(MapView map, Style defaultStyle, Styler styler, KmlPlacemark kmlPlacemark, 
		KmlDocument kmlDocument){
	Context context = map.getContext();
	Polygon polygonOverlay = new Polygon(context);
	polygonOverlay.setPoints(mCoordinates);
	if (mHoles != null)
		polygonOverlay.setHoles(mHoles);
	polygonOverlay.setTitle(kmlPlacemark.mName);
	polygonOverlay.setSnippet(kmlPlacemark.mDescription);
	polygonOverlay.setSubDescription(kmlPlacemark.getExtendedDataAsText());
	if (styler == null)
		applyDefaultStyling(polygonOverlay, defaultStyle, kmlPlacemark, kmlDocument, map);
	else
		styler.onPolygon(polygonOverlay, kmlPlacemark, this);
	return polygonOverlay;
}
 
开发者ID:jeffallen,项目名称:MarshrutMe,代码行数:18,代码来源:KmlPolygon.java

示例6: applyDefaultStyling

import org.osmdroid.views.MapView; //导入方法依赖的package包/类
public void applyDefaultStyling(Polyline lineStringOverlay, Style defaultStyle, KmlPlacemark kmlPlacemark,
		KmlDocument kmlDocument, MapView map){
	Context context = map.getContext();
	Style style = kmlDocument.getStyle(kmlPlacemark.mStyle);
	if (style != null){
		lineStringOverlay.setColor(style.getOutlinePaint().getColor());
		lineStringOverlay.setWidth(style.getOutlinePaint().getStrokeWidth());
	} else if (defaultStyle!=null && defaultStyle.mLineStyle!=null){
		lineStringOverlay.setColor(defaultStyle.getOutlinePaint().getColor());
		lineStringOverlay.setWidth(defaultStyle.getOutlinePaint().getStrokeWidth());
	}
	if ((kmlPlacemark.mName!=null && !"".equals(kmlPlacemark.mName))
			|| (kmlPlacemark.mDescription!=null && !"".equals(kmlPlacemark.mDescription))
			|| (lineStringOverlay.getSubDescription()!=null && !"".equals(lineStringOverlay.getSubDescription()))
			){
		if (mDefaultLayoutResId == BonusPackHelper.UNDEFINED_RES_ID){
			String packageName = context.getPackageName();
			mDefaultLayoutResId = context.getResources().getIdentifier("layout/bonuspack_bubble", null, packageName);
		}
		lineStringOverlay.setInfoWindow(new BasicInfoWindow(mDefaultLayoutResId, map));
	}
	lineStringOverlay.setEnabled(kmlPlacemark.mVisibility);
}
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:24,代码来源:KmlTrack.java

示例7: NavigateInfoWindow

import org.osmdroid.views.MapView; //导入方法依赖的package包/类
public NavigateInfoWindow(MapView mapView, final Marker marker) {
    super(R.layout.bonuspack_bubble, mapView);

    Context context = mapView.getContext();
    String packageName = context.getPackageName();
    list = (ListView)this.mView.findViewById(R.id.bubble_list);
    list.setVisibility(View.VISIBLE);



    ArrayList<String> array = new ArrayList<String>();
    adapter = new ArrayAdapter<String>(context, R.layout.property_list_item, array);
    list.setAdapter(adapter);

    naviBtn = (Button)(mView.findViewById(R.id.bubble_btn));
    naviBtn.setText("Navigate");
    naviBtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            fetchRoadAndDisplay(mUserLocation, marker.getPosition());
        }
    });

    closeBtn = (Button)(mView.findViewById(R.id.bubble_close));
    closeBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            close();
        }
    });
}
 
开发者ID:OpenISDM,项目名称:madapp,代码行数:31,代码来源:MapFragment.java

示例8: InfoWindow

import org.osmdroid.views.MapView; //导入方法依赖的package包/类
/**
 * @param layoutResId	the id of the view resource. 
 * @param mapView	the mapview on which is hooked the view
 */
public InfoWindow(int layoutResId, MapView mapView) {
	mMapView = mapView;
	mIsVisible = false;
	ViewGroup parent=(ViewGroup)mapView.getParent();
	Context context = mapView.getContext();
	LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	mView = inflater.inflate(layoutResId, parent, false);
	mView.setTag(this);
}
 
开发者ID:jeffallen,项目名称:MarshrutMe,代码行数:14,代码来源:InfoWindow.java

示例9: buildOverlay

import org.osmdroid.views.MapView; //导入方法依赖的package包/类
/** @return the corresponding GroundOverlay ready to display on the map */
@Override public Overlay buildOverlay(MapView map, Style defaultStyle, Styler styler, KmlDocument kmlDocument){
	Context context = map.getContext();
	GroundOverlay overlay = new GroundOverlay(context);
	if (mCoordinates.size()==2){
		GeoPoint pNW = mCoordinates.get(0);
		GeoPoint pSE = mCoordinates.get(1);
		overlay.setPosition(GeoPoint.fromCenterBetween(pNW, pSE));
		GeoPoint pNE = new GeoPoint(pNW.getLatitude(), pSE.getLongitude());
		int width = pNE.distanceTo(pNW);
		GeoPoint pSW = new GeoPoint(pSE.getLatitude(), pNW.getLongitude());
		int height = pSW.distanceTo(pNW);
		overlay.setDimensions((float)width, (float)height);
	}
	//TODO: else if size=4, nonrectangular quadrilateral
	
	if (mIcon != null){
		overlay.setImage(new BitmapDrawable(mIcon));
		//TODO: not clearly defined in KML spec, but color is supposed to be blended with the image. 
		float transparency = 1.0f - Color.alpha(mColor)/255.0f; //KML transparency is the transparency part of the "color" element. 
		overlay.setTransparency(transparency);
	} else {
		//when no image available, set it as a rectangle filled with the KML color
		Bitmap bitmap = Bitmap.createBitmap(2, 2, Bitmap.Config.ARGB_8888);
		bitmap.eraseColor(mColor);
		overlay.setImage(new BitmapDrawable(bitmap));
	}
	
	overlay.setBearing(-mRotation); //from KML counterclockwise to Google Maps API which is clockwise
	if (styler == null)
		overlay.setEnabled(mVisibility);
	else 
		styler.onFeature(overlay, this);
	return overlay;
}
 
开发者ID:jeffallen,项目名称:MarshrutMe,代码行数:36,代码来源:KmlGroundOverlay.java

示例10: buildOverlay

import org.osmdroid.views.MapView; //导入方法依赖的package包/类
/**
 * Build a FolderOverlay, containing (recursively) overlays from all items of this Folder. 
 * @param map
 * @param defaultStyle to apply when an item has no Style defined. 
 * @param styler to apply
 * @param kmlDocument for Styles
 * @return the FolderOverlay built
 */
@Override public Overlay buildOverlay(MapView map, Style defaultStyle, Styler styler, KmlDocument kmlDocument){
	Context context = map.getContext();
	FolderOverlay folderOverlay = new FolderOverlay(context);
	for (KmlFeature k:mItems){
		Overlay overlay = k.buildOverlay(map, defaultStyle, styler, kmlDocument);
		folderOverlay.add(overlay);
	}
	if (styler == null)
		folderOverlay.setEnabled(mVisibility);
	else 
		styler.onFeature(folderOverlay, this);
	return folderOverlay;
}
 
开发者ID:jeffallen,项目名称:MarshrutMe,代码行数:22,代码来源:KmlFolder.java

示例11: applyDefaultStyling

import org.osmdroid.views.MapView; //导入方法依赖的package包/类
public void applyDefaultStyling(Marker marker, Style defaultStyle, KmlPlacemark kmlPlacemark,
		KmlDocument kmlDocument, MapView map){
	Context context = map.getContext();
	Style style = kmlDocument.getStyle(kmlPlacemark.mStyle);
	if (style != null && style.mIconStyle != null){
		style.mIconStyle.styleMarker(marker, context);
	} else if (defaultStyle!=null && defaultStyle.mIconStyle!=null){
		defaultStyle.mIconStyle.styleMarker(marker, context);
	}
	//allow marker drag, acting on KML Point:
	marker.setDraggable(true);
	marker.setOnMarkerDragListener(new OnKMLMarkerDragListener());
	marker.setEnabled(kmlPlacemark.mVisibility);
}
 
开发者ID:jeffallen,项目名称:MarshrutMe,代码行数:15,代码来源:KmlPoint.java

示例12: buildOverlay

import org.osmdroid.views.MapView; //导入方法依赖的package包/类
/** Build a FolderOverlay containing all overlays from this MultiGeometry items */
@Override public Overlay buildOverlay(MapView map, Style defaultStyle, Styler styler, KmlPlacemark kmlPlacemark, 
		KmlDocument kmlDocument){
	Context context = map.getContext();
	FolderOverlay folderOverlay = new FolderOverlay(context);
	for (KmlGeometry k:mItems){
		Overlay overlay = k.buildOverlay(map, defaultStyle, styler, kmlPlacemark, kmlDocument);
		folderOverlay.add(overlay);
	}
	return folderOverlay;
}
 
开发者ID:jeffallen,项目名称:MarshrutMe,代码行数:12,代码来源:KmlMultiGeometry.java

示例13: MyMarker

import org.osmdroid.views.MapView; //导入方法依赖的package包/类
public MyMarker(MapView mapView) {
    this(mapView, new DefaultResourceProxyImpl(mapView.getContext()));
}
 
开发者ID:Arman92,项目名称:Mapsforge-OsmDroid-GraphHopper,代码行数:4,代码来源:MyMarker.java

示例14: Marker

import org.osmdroid.views.MapView; //导入方法依赖的package包/类
public Marker(MapView mapView) {
	this(mapView, new DefaultResourceProxyImpl(mapView.getContext()));
}
 
开发者ID:jeffallen,项目名称:MarshrutMe,代码行数:4,代码来源:Marker.java


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