本文整理汇总了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));
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}