本文整理匯總了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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
});
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例13: MyMarker
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
public MyMarker(MapView mapView) {
this(mapView, new DefaultResourceProxyImpl(mapView.getContext()));
}
示例14: Marker
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
public Marker(MapView mapView) {
this(mapView, new DefaultResourceProxyImpl(mapView.getContext()));
}