當前位置: 首頁>>代碼示例>>Java>>正文


Java MapView類代碼示例

本文整理匯總了Java中org.osmdroid.views.MapView的典型用法代碼示例。如果您正苦於以下問題:Java MapView類的具體用法?Java MapView怎麽用?Java MapView使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MapView類屬於org.osmdroid.views包,在下文中一共展示了MapView類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addMarker

import org.osmdroid.views.MapView; //導入依賴的package包/類
public static void addMarker(Context context, MapView map, Element element) {
    Marker marker = new Marker(map);
    marker.setPosition(new GeoPoint(element.lat, element.lon));
    marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
    map.getOverlays().add(marker);
    map.invalidate();
    marker.setIcon(context.getResources().getDrawable(R.drawable.ic_location));

    marker.setTitle(String.valueOf(""));
    for (Map.Entry<String, String> tag : element.tags.entrySet()) {
        if (tag.getKey().equals("name")) {
            marker.setTitle(String.valueOf(tag.getValue()));
            break;
        }
    }
    if (marker.getTitle().equals(""))
        marker.setTitle(String.valueOf(element.id));

}
 
開發者ID:CityZenApp,項目名稱:Android-Development,代碼行數:20,代碼來源:MapUtils.java

示例2: buildClusterMarker

import org.osmdroid.views.MapView; //導入依賴的package包/類
@Override public Marker buildClusterMarker(StaticCluster cluster, MapView mapView) {
    Marker m = new Marker(mapView);
    m.setPosition(cluster.getPosition());
    m.setInfoWindow(null);
    m.setAnchor(mAnchorU, mAnchorV);

    Bitmap finalIcon = Bitmap.createBitmap(mClusterIcon.getWidth(), mClusterIcon.getHeight(), mClusterIcon.getConfig());
    Canvas iconCanvas = new Canvas(finalIcon);
    iconCanvas.drawBitmap(mClusterIcon, 0, 0, null);
    String text = "" + cluster.getSize();
    int textHeight = (int) (mTextPaint.descent() + mTextPaint.ascent());
    iconCanvas.drawText(text,
            mTextAnchorU * finalIcon.getWidth(),
            mTextAnchorV * finalIcon.getHeight() - textHeight / 2,
            mTextPaint);
    m.setIcon(new BitmapDrawable(mapView.getContext().getResources(), finalIcon));

    return m;
}
 
開發者ID:jeffallen,項目名稱:MarshrutMe,代碼行數:20,代碼來源:RadiusMarkerClusterer.java

示例3: getClusterMarkerIcon

import org.osmdroid.views.MapView; //導入依賴的package包/類
/** calculates the icon for the clusterMarker (with text = number of items) */
protected BitmapDrawable getClusterMarkerIcon(String text, MapView mapView) {

    // this works for android 4.4 but not thows an exception in android 2.1
    // Bitmap finalIcon = Bitmap.createBitmap(mClusterIcon.getWidth(), mClusterIcon.getHeight(), mClusterIcon.getConfig());
    // this works with android2.1
    Bitmap finalIcon = Bitmap.createBitmap(mClusterIcon.getWidth(), mClusterIcon.getHeight(), Bitmap.Config.ARGB_8888);

    Canvas iconCanvas = new Canvas(finalIcon);
    iconCanvas.drawBitmap(mClusterIcon, 0, 0, null);
    int textHeight = (int) (mTextPaint.descent() + mTextPaint.ascent());
    iconCanvas.drawText(text,
            mTextAnchorU * finalIcon.getWidth(),
            mTextAnchorV * finalIcon.getHeight() - textHeight / 2,
            mTextPaint);
    return new BitmapDrawable(mapView.getContext().getResources(), finalIcon);
}
 
開發者ID:k3b,項目名稱:LocationMapViewer,代碼行數:18,代碼來源:RadiusMarkerClustererWithInfo.java

示例4: mapSetup

import org.osmdroid.views.MapView; //導入依賴的package包/類
private void mapSetup() {
    map = (MapView) getActivity().findViewById(R.id.createPoiMap);

    //important! set your user agent to prevent getting banned from the osm servers
    Configuration.getInstance().load(getActivity(), PreferenceManager.getDefaultSharedPreferences(getActivity()));

    map.setTileSource(TileSourceFactory.MAPNIK);
    map.setTilesScaledToDpi(true);

    // add multi-touch capability
    map.setMultiTouchControls(true);

    // add compass to map
    CompassOverlay compassOverlay = new CompassOverlay(getActivity(), new InternalCompassOrientationProvider(getActivity()), map);
    compassOverlay.enableCompass();
    map.getOverlays().add(compassOverlay);

    // get map controller
    IMapController controller = map.getController();

    GeoPoint position = new GeoPoint(latitude, longitude);
    controller.setCenter(position);
    controller.setZoom(18);
    MapUtils.addMarker(getActivity(), map, latitude, longitude);
}
 
開發者ID:CityZenApp,項目名稱:Android-Development,代碼行數:26,代碼來源:CreatePoiFragment.java

示例5: mapSetup

import org.osmdroid.views.MapView; //導入依賴的package包/類
private void mapSetup() {
    map = (MapView) getActivity().findViewById(R.id.map);  // create basic map
    mController = map.getController(); // get map controller
    map.setTileSource(TileSourceFactory.MAPNIK);
    map.setTilesScaledToDpi(true);
    map.setMultiTouchControls(true);

    // add compass to map
    CompassOverlay compassOverlay = new CompassOverlay(getActivity(), new InternalCompassOrientationProvider(getActivity()), map);
    compassOverlay.enableCompass();
    map.getOverlays().add(compassOverlay);

    //attach listeners
    MapEventsOverlay mapEventsOverlay = new MapEventsOverlay(this);
    map.getOverlays().add(0, mapEventsOverlay);
    setupMyLocation();
}
 
開發者ID:CityZenApp,項目名稱:Android-Development,代碼行數:18,代碼來源:MapFragment.java

示例6: setupMapPreview

import org.osmdroid.views.MapView; //導入依賴的package包/類
private void setupMapPreview(double lat, double lon, String markerTitle) {
    //important! set your user agent to prevent getting banned from the osm servers
    Configuration.getInstance().load(getDialog().getContext(), PreferenceManager.getDefaultSharedPreferences(getDialog().getContext()));

    map = (MapView) getDialog().findViewById(R.id.poiDialogMap);
    map.setTileSource(TileSourceFactory.MAPNIK);
    map.setTilesScaledToDpi(true);
    map.setMultiTouchControls(true);

    // add compass to map
    CompassOverlay compassOverlay = new CompassOverlay(getDialog().getContext(), new InternalCompassOrientationProvider(getDialog().getContext()), map);
    compassOverlay.enableCompass();
    map.getOverlays().add(compassOverlay);

    // get map controller
    IMapController controller = map.getController();
    GeoPoint position = new GeoPoint(lat, lon);
    controller.setCenter(position);
    controller.setZoom(18);

    MapUtils.addMarker(getActivity(), map, lat, lon, markerTitle);
}
 
開發者ID:CityZenApp,項目名稱:Android-Development,代碼行數:23,代碼來源:PoiDetailsFragment.java

示例7: mapSetup

import org.osmdroid.views.MapView; //導入依賴的package包/類
private void mapSetup() {
    map = (MapView) getActivity().findViewById(R.id.createPoiMap);
    //important! set your user agent to prevent getting banned from the osm servers
    Configuration.getInstance().load(getActivity(), PreferenceManager.getDefaultSharedPreferences(getActivity()));
    map.setTileSource(TileSourceFactory.MAPNIK);
    map.setTilesScaledToDpi(true);
    map.setMultiTouchControls(true);

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

    IMapController controller = map.getController();
    GeoPoint position = new GeoPoint(POI.getLatitude(), POI.getLongitude());
    controller.setCenter(position);
    controller.setZoom(18);

    MapUtils.addMarker(getActivity(), map, POI.getLatitude(), POI.getLongitude());
}
 
開發者ID:CityZenApp,項目名稱:Android-Development,代碼行數:20,代碼來源:EditPoiFragment.java

示例8: onMarkerClick

import org.osmdroid.views.MapView; //導入依賴的package包/類
@Override
public boolean onMarkerClick(Marker marker, MapView mapView) {
    CellTowerMarker cellTowerMarker = (CellTowerMarker) marker;
    AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
    dialog.setTitle(cellTowerMarker.getTitle());
    dialog.setView(getInfoContents(cellTowerMarker.getMarkerData()));
    dialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            dialogInterface.dismiss();
        }
    });
    dialog.show();

    return true;
}
 
開發者ID:5GSD,項目名稱:AIMSICDL,代碼行數:17,代碼來源:CellTowerMarker.java

示例9: onCreateView

import org.osmdroid.views.MapView; //導入依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_map, container, false);
    Context ctx = getActivity().getApplicationContext();
    //important! set your user agent to prevent getting banned from the osm servers
    Configuration.getInstance().load(ctx, PreferenceManager.getDefaultSharedPreferences(ctx));
    Configuration.getInstance().setUserAgentValue(BuildConfig.APPLICATION_ID);

    if (ContextCompat.checkSelfPermission(getActivity(),
            Manifest.permission.WRITE_EXTERNAL_STORAGE)
            != PackageManager.PERMISSION_GRANTED) {

        // Should we show an explanation?
        if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity() ,Manifest.permission.WRITE_EXTERNAL_STORAGE)) {

            // Show an explanation to the user *asynchronously* -- don't block
            // this thread waiting for the user's response! After the user
            // sees the explanation, try again to request the permission.

        } else {

            // No explanation needed, we can request the permission.

            ActivityCompat.requestPermissions(getActivity(),
                    new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                    PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE);

            // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
            // app-defined int constant. The callback method gets the
            // result of the request.
        }
    }
    map = (MapView) v.findViewById(R.id.map);
    map.setTileSource(TileSourceFactory.MAPNIK);
    configMap();

    return v;
}
 
開發者ID:DecentralizedAmateurPagingNetwork,項目名稱:DAPNETApp,代碼行數:41,代碼來源:MapFragment.java

示例10: putMarker

import org.osmdroid.views.MapView; //導入依賴的package包/類
public static Marker putMarker(Context context, MapView map, GeoPoint position, int resourceId,
    float horizontalAnchor, float verticalAnchor, boolean isDraggable)
{
    Marker marker = new Marker(map);
    marker.setPosition(position);
    marker.setAnchor(horizontalAnchor, verticalAnchor);
    marker.setDraggable(isDraggable);

    setMarkerIconFromResource(context, resourceId, marker);

    map.getOverlays().add(marker);
    map.invalidate();

    return marker;
}
 
開發者ID:LenaShervarly,項目名稱:TreasureHunting,代碼行數:16,代碼來源:MapHelper.java

示例11: chooseBeautifulMapProvider

import org.osmdroid.views.MapView; //導入依賴的package包/類
public static void chooseBeautifulMapProvider(Context context, MapView map)
{
    MapBoxTileSource tileSource = new MapBoxTileSource(context);
    map.setTilesScaledToDpi(true);
    tileSource.setMapboxMapid("mapbox.emerald");
    map.setTileSource(tileSource);
}
 
開發者ID:LenaShervarly,項目名稱:TreasureHunting,代碼行數:8,代碼來源:MapHelper.java

示例12: drawRoute

import org.osmdroid.views.MapView; //導入依賴的package包/類
public static void drawRoute(Context context, MapView map, List<Point> points) {
    Polyline line = new Polyline(context);

    line.setSubDescription(Polyline.class.getCanonicalName());
    line.setWidth(15f);
    line.setColor(ContextCompat.getColor(context, R.color.orange_partially_transparent));

    List<GeoPoint> geoPoints = new ArrayList<>();

    for(Point point : points) {

        geoPoints.add(point.Position);
    }

    line.setPoints(geoPoints);
    line.setGeodesic(true);
    map.getOverlayManager().add(line);
}
 
開發者ID:LenaShervarly,項目名稱:TreasureHunting,代碼行數:19,代碼來源:MapHelper.java

示例13: drawAudioPoints

import org.osmdroid.views.MapView; //導入依賴的package包/類
public static void drawAudioPoints(Context context, MapView map, AudioPlaybackController controller,
                                   Game excursion, List<Marker> markers) {
    final boolean isDebug = (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;

    for(AudioPoint point : excursion.getAudioPoints())
    {
        boolean isPointPassed = controller.isAudioPointPassed(point.Number);
        int resId = isPointPassed
                ? R.drawable.passed
                : R.drawable.game_point_big;

        float anchor = isPointPassed
                ? Marker.ANCHOR_CENTER
                : Marker.ANCHOR_BOTTOM;

        Marker marker = putMarker(context, map, point.Position, resId, Marker.ANCHOR_CENTER, anchor, isDebug);
        markers.add(marker);

    }
}
 
開發者ID:LenaShervarly,項目名稱:TreasureHunting,代碼行數:21,代碼來源:MapHelper.java

示例14: tileSource

import org.osmdroid.views.MapView; //導入依賴的package包/類
public MapView tileSource(String type) {
    OnlineTileSourceBase source;
    if (type.equals("hikebikemap")) {
        source = TileSourceFactory.HIKEBIKEMAP;
    } else {
        source = TileSourceFactory.MAPNIK;
    }

    mapView.setTileSource(source);

    return mapView;
}
 
開發者ID:victordiaz,項目名稱:phonk,代碼行數:13,代碼來源:PMap.java

示例15: onCreate

import org.osmdroid.views.MapView; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    MapView mapView = (MapView) findViewById(R.id.map_view);
    mapView.setTileSource(TileSourceFactory.PUBLIC_TRANSPORT);
    mapView.setBuiltInZoomControls(true);
    mapView.setMultiTouchControls(true);

    IMapController mapController = mapView.getController();
    mapController.setZoom(9);
    GeoPoint location = new GeoPoint(27.7166667,85.3166667);
    mapController.setCenter(location);
}
 
開發者ID:SiyaOrg,項目名稱:buseto,代碼行數:17,代碼來源:MainActivity.java


注:本文中的org.osmdroid.views.MapView類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。