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


Java MapView.invalidate方法代碼示例

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


在下文中一共展示了MapView.invalidate方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例3: onCreateView

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
    mContext = inflater.getContext();
    mResourceProxy = new ResourceProxyImpl(mContext.getApplicationContext());
    mMapView = new MapView(inflater.getContext(), 256, mResourceProxy);
    mMapView.setTileSource(TileSourceFactory.MAPQUESTOSM);
    mMapView.setBuiltInZoomControls(true);
    mMapView.setMultiTouchControls(true);
    mMapView.setUseDataConnection(true);
    IMapController mapCtrl = mMapView.getController();
    mapCtrl.setCenter(new GeoPoint(43.5, -80.5));
    mapCtrl.setZoom(10);
    mMapView.invalidate();

    return mMapView;
}
 
開發者ID:TotalVerb,項目名稱:findr-android,代碼行數:18,代碼來源:FindrMapView.java

示例4: myLocation

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
public static Marker myLocation(Context context, MapView map, double latitude, double longitude) {
    if (map == null || context == null) return null;
    Marker marker = new Marker(map);
    marker.setPosition(new GeoPoint(latitude, longitude));
    marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
    marker.setIcon(context.getResources().getDrawable(R.drawable.ic_gps_location));
    marker.setInfoWindow(null);
    map.getOverlays().add(marker);
    map.invalidate();
    return marker;
}
 
開發者ID:CityZenApp,項目名稱:Android-Development,代碼行數:12,代碼來源:MapUtils.java

示例5: OsmPolyline

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
public OsmPolyline(PolylineOptions polylineOptions, MapView osmMap) {
    this.osmMap = osmMap;
    org.osmdroid.views.overlay.Polyline polyline = new org.osmdroid.views.overlay.Polyline();
    polyline.setColor(polylineOptions.getColor());
    polyline.setVisible(polylineOptions.isVisible());
    ArrayList<GeoPoint> points = new ArrayList<>();
    for (LatLng latlng : polylineOptions.getPoints()){
        points.add(new GeoPoint(latlng.latitude,latlng.longitude));
    }
    polyline.setPoints(points);
    polyline.setWidth(polylineOptions.getWidth());
    osmMap.getOverlayManager().add(polyline);
    osmMap.invalidate();
    osmPolyline = polyline;
}
 
開發者ID:RSDT,項目名稱:Japp16,代碼行數:16,代碼來源:OsmPolyline.java

示例6: if

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
@Override public boolean 	onDoubleTapEvent(MotionEvent ev, MapView mapView) {
    if (this.isEnabled()) {
        switch (ev.getAction() & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_DOWN:
                startRecordClipboard();
                this.mStart = new Point((int) ev.getX(), (int) ev.getY());
                this.mEnd = new Point();
                this.mPaint = new Paint();
                this.mPaint.setColor(colorDragTo);
                this.mPaint.setStrokeWidth(3);
                setEndPoint("onDoubleTapEvent-ACTION_DOWN", ev, mapView);
                break;
            case MotionEvent.ACTION_MOVE:
                if (setEndPoint("onDoubleTapEvent-ACTION_MOVE", ev, mapView)) {
                    mapView.invalidate();

                    return true; // i have handled it
                }
                break;
            case MotionEvent.ACTION_UP: {
                boolean visible = setEndPoint("onDoubleTapEvent-ACTION_UP", ev, mapView);
                zoom(mapView, visible);
                // this.mStart = null;
                // this.mRect = null;
                // this.mPaint = null;
                // this.mRectVisible = false;
                if (isDebugEnabled()) {
                    this.copyDebugToClipboard(mapView.getContext());
                }
                this.mRectVisible = false;
                return true; // processed
            }
        }
        if (isDebugEnabled()) debug("onDoubleTapEvent", this, ev);
    }
    return super.onDoubleTapEvent(ev, mapView); // false: not handled yet
}
 
開發者ID:k3b,項目名稱:LocationMapViewer,代碼行數:38,代碼來源:GuestureOverlay.java

示例7: OsmMarker

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
public OsmMarker(Pair<MarkerOptions,Bitmap> markerOptionsPair, MapView osmMap) {
    this.osmMap = osmMap;
    osmMarker = new org.osmdroid.views.overlay.Marker(osmMap);
    MarkerOptions markerOptions = markerOptionsPair.first;
    this.setIcon(markerOptionsPair.second);
    this.setPosition(markerOptions.getPosition());

    if(markerOptions.getTitle() != null && !markerOptions.getTitle().isEmpty()) {
        StringBuilder buff = new StringBuilder();
        MarkerIdentifier identifier = null;
        try {
            identifier = new Gson().fromJson(markerOptions.getTitle(), MarkerIdentifier.class);
        }
        catch(Exception e) {
            Log.e("OsmMarker", e.toString());
        }
        if(identifier != null) {
            HashMap<String, String> properties = identifier.getProperties();
            switch (identifier.getType()) {
                case MarkerIdentifier.TYPE_VOS:
                    buff.append(properties.get("extra")).append("\n");
                    buff.append(properties.get("time")).append("\n");
                    buff.append(properties.get("note")).append("\n");
                    buff.append(properties.get("team")).append("\n");
                    break;
                case MarkerIdentifier.TYPE_HUNTER:
                    buff.append(properties.get("hunter")).append("\n");
                    buff.append(properties.get("time")).append("\n");
                    break;
                case MarkerIdentifier.TYPE_SC:
                    buff.append(properties.get("name")).append("\n");
                    buff.append(properties.get("adres")).append("\n");
                    buff.append(properties.get("team")).append("\n");
                    break;
                case MarkerIdentifier.TYPE_NAVIGATE_CAR:
                    buff.append("Dit is waar de navigatie telefoon naartoe naar navigeerd");
                    buff.append("\n");
                    buff.append("geplaatst door: ");
                    buff.append(properties.get("addedBy"));
                    //todo voeg leuk icoon toe
                    break;
                case MarkerIdentifier.TYPE_NAVIGATE:
                    buff.append("Hier naar zal je genavigeerd worden!");
                    break;
            }
            osmMarker.setTitle(buff.toString());
        } else {
            osmMarker.setTitle(markerOptions.getTitle());
        }
    }



    osmMarker.setOnMarkerClickListener(new org.osmdroid.views.overlay.Marker.OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(org.osmdroid.views.overlay.Marker marker, MapView mapView) {
            if (marker == osmMarker) {
                onClick();
            }
            return false;
        }
    });
    osmMap.getOverlays().add(osmMarker);
    osmMap.invalidate();
}
 
開發者ID:RSDT,項目名稱:Japp16,代碼行數:66,代碼來源:OsmMarker.java

示例8: drawRoadWithWaypoints

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
/**
 * Draws the WayPoints of the Road, with instructions on them
 * @param road The Road we are going to add the WayPoints to
 * @param map The MapView on which the WayPoints will be added
 */
public void drawRoadWithWaypoints(Road road, MapView map) {
    /* TODO add support for even more directions markers type */
    Drawable nodeIcon = ContextCompat.getDrawable(context, R.drawable.marker_node);
    for (int i = 0; i < road.mNodes.size(); i++) {
        RoadNode node = road.mNodes.get(i); // We get the i-ème node of the route
        Marker nodeMarker = new Marker(map);
        nodeMarker.setPosition(node.mLocation);
        nodeMarker.setIcon(nodeIcon);
        nodeMarker.setTitle(context.getString(R.string.step_nbr) + " " + i);
        map.getOverlays().add(nodeMarker);

        // And we fill the bubbles with the directions
        nodeMarker.setSnippet(node.mInstructions);
        nodeMarker.setSubDescription(Road.getLengthDurationText(node.mLength, node.mDuration));

        // Finally, we add an icon to the bubble
        Drawable icon = ContextCompat.getDrawable(context, R.drawable.ic_continue);
        switch (node.mManeuverType) {
            case 1:
                icon = ContextCompat.getDrawable(context, R.drawable.ic_continue);
                break;
            case 3:
                icon = ContextCompat.getDrawable(context, R.drawable.ic_slight_left);
                break;
            case 4:
                icon = ContextCompat.getDrawable(context, R.drawable.ic_turn_left);
                break;
            case 5:
                icon = ContextCompat.getDrawable(context, R.drawable.ic_sharp_left);
                break;
            case 6:
                icon = ContextCompat.getDrawable(context, R.drawable.ic_slight_right);
                break;
            case 7:
                icon = ContextCompat.getDrawable(context, R.drawable.ic_turn_right);
                break;
            case 8:
                icon = ContextCompat.getDrawable(context, R.drawable.ic_sharp_right);
                break;
            case 12:
                icon = ContextCompat.getDrawable(context, R.drawable.ic_u_turn);
                break;
            default:
                break;

        }
        nodeMarker.setImage(icon);
    }
    map.invalidate();
}
 
開發者ID:WikiJourney,項目名稱:wikijourney_app,代碼行數:56,代碼來源:Routing.java

示例9: moveToEventPosition

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
public void moveToEventPosition(MotionEvent event, MapView mapView) {
    Projection pj = mapView.getProjection();
    this.mPosition = (GeoPoint)pj.fromPixels((int)event.getX(), (int)event.getY());
    mapView.invalidate();
}
 
開發者ID:Arman92,項目名稱:Mapsforge-OsmDroid-GraphHopper,代碼行數:6,代碼來源:MyMarker.java

示例10: moveToEventPosition

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
public void moveToEventPosition(final MotionEvent event, final MapView mapView){
    final Projection pj = mapView.getProjection();
    mPosition = (GeoPoint) pj.fromPixels((int)event.getX(), (int)event.getY());
    mapView.invalidate();
}
 
開發者ID:Arman92,項目名稱:Mapsforge-OsmDroid-GraphHopper,代碼行數:6,代碼來源:MyLocationNewOverlay.java

示例11: moveToEventPosition

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
public void moveToEventPosition(final MotionEvent event, final MapView mapView){
	final Projection pj = mapView.getProjection();
	mPosition = (GeoPoint) pj.fromPixels((int)event.getX(), (int)event.getY());
	mapView.invalidate();
}
 
開發者ID:jeffallen,項目名稱:MarshrutMe,代碼行數:6,代碼來源:Marker.java

示例12: onCreate

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

    final MapView mapView = (MapView) findViewById(R.id.map);

    final MapBoxTileSource tileSource = new MapBoxTileSource("mapbox", 1, 20, 256, ".png");
    tileSource.retrieveAccessToken(this);
    tileSource.retrieveMapBoxMapId(this);
    mapView.setTileSource(tileSource);

    /* Set map controls */
    mapView.setMultiTouchControls(true);

    mapView.getController().setCenter(new GeoPoint(pMapInitLat, pMapInitLon));
    mapView.getController().setZoom(18);
    mapView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

    mapView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    currentAccount = TranSappAccountManager.getCurrentAccount();

    if (currentAccount == null) {
        this.finish();
        return;
    }

    serverBusAvatarId = currentAccount.getBusAvatarId();
    busAvatarId = serverBusAvatarId;

    final ActiveBusView activeBusView = new ActiveBusView(this, "506v", serverBusAvatarId, false);

    final Marker startMarker = new Marker(mapView);
    startMarker.setPosition(new GeoPoint(pInitLat, pInitLon));
    startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
    startMarker.setIcon(activeBusView.getBitmapDrawable());

    mapView.getOverlays().add(startMarker);


    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.bus_picker_recycler_view);

    BusAvatarRowAdapter adapter = new BusAvatarRowAdapter(this, AvatarLists.BUS_AVATARS, new BusAvatarRowAdapter.AvatarClickListener() {
        @Override
        public void onNewAvatarSelected(int serverId) {
            busAvatarId = serverId;
            activeBusView.setAvatarId(serverId);
            startMarker.setIcon(activeBusView.getBitmapDrawable());
            mapView.invalidate();
        }
    }, currentAccount.getLevelPosition(), currentAccount.getBusAvatarId());

    recyclerView.setLayoutManager(new LinearLayoutManager(this));

    recyclerView.setAdapter(adapter);
    recyclerView.invalidate();
}
 
開發者ID:InspectorIncognito,項目名稱:androidApp,代碼行數:64,代碼來源:AccountBusPickerActivity.java

示例13: deleteMarker

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
/**
 * Delete a marker from map
 *
 * @param marker {@link Marker} to be deleted
 * @param map    The {@link MapView} which holds the marker
 */
public static void deleteMarker(Marker marker, MapView map) {
    map.getOverlays().remove(marker);
    map.invalidate();
}
 
開發者ID:CityZenApp,項目名稱:Android-Development,代碼行數:11,代碼來源:MapUtils.java

示例14: drawPolyline

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
/**
 * Creates Polyline to bind nodes of the route, and draw it
 * @param route The Road calcuated between each GeoPoint
 * @param map The MapView to draw the Road on
 * @param context Needed to draw the Road, should be the Activity containing the MapView
 */
public void drawPolyline(Road route, MapView map, Context context) {
    Polyline roadOverlay = RoadManager.buildRoadOverlay(route, context);
    map.getOverlays().add(roadOverlay);
    map.invalidate();
}
 
開發者ID:WikiJourney,項目名稱:wikijourney_app,代碼行數:12,代碼來源:Routing.java


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