本文整理汇总了Java中org.osmdroid.events.MapListener类的典型用法代码示例。如果您正苦于以下问题:Java MapListener类的具体用法?Java MapListener怎么用?Java MapListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MapListener类属于org.osmdroid.events包,在下文中一共展示了MapListener类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scrollTo
import org.osmdroid.events.MapListener; //导入依赖的package包/类
@Override
public void scrollTo(int x, int y) {
setMapScroll(x, y);
resetProjection();
invalidate();
// Force a layout, so that children are correctly positioned according to map orientation
if (getMapOrientation() != 0f)
myOnLayout(true, getLeft(), getTop(), getRight(), getBottom());
// do callback on listener
for (MapListener mapListener: mListners){
final ScrollEvent event = new ScrollEvent(this, x, y);
mapListener.onScroll(event);
}
}
示例2: setCenter
import org.osmdroid.events.MapListener; //导入依赖的package包/类
/**
* Set the map view to the given center. There will be no animation.
*/
@Override
public void setCenter(final IGeoPoint point) {
// If no layout, delay this call
for (MapListener mapListener: mMapView.mListners) {
mapListener.onScroll(new ScrollEvent(mMapView, 0, 0));
}
if (!mMapView.isLayoutOccurred()) {
mReplayController.setCenter(point);
return;
}
mMapView.setExpectedCenter(point);
}
示例3: onCreateView
import org.osmdroid.events.MapListener; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) {
Log.d(TAG, "onCreateView");
View createdView;
if (getMapLayoutId() == -1) {
LinearLayout linearLayout =
(LinearLayout) inflater.inflate(getLayoutId(), container, false);
linearLayout.addView(this.mapView);
createdView = linearLayout;
} else {
createdView = inflater.inflate(getLayoutId(), container, false);
LinearLayout mapLayout = (LinearLayout) createdView.findViewById(getMapLayoutId());
mapLayout.addView(this.mapView);
}
this.mapView.setMapListener(
new DelayedMapListener(
new MapListener() {
Integer x, y;
public boolean onZoom(final ZoomEvent zoomEvent) {
Log.i(TAG, "onZoom: " + zoomEvent.getZoomLevel());
currentStrategy.onMapDisplacement(
mapView.getZoomLevel(),
mapView.getMapCenter().getLatitude(),
mapView.getMapCenter().getLongitude());
return true;
}
public boolean onScroll(final ScrollEvent e) {
Log.d(TAG, "onScroll");
MapFragment.this.onScroll();
if (x == null || y == null) {
x = e.getX();
y = e.getY();
} else if (x == e.getX() && y == e.getY()) {
return true;
}
currentStrategy.onMapDisplacement(
mapView.getZoomLevel(),
mapView.getMapCenter().getLatitude(),
mapView.getMapCenter().getLongitude());
return true;
}
}, 200));
return createdView;
}
示例4: zoomToFixing
import org.osmdroid.events.MapListener; //导入依赖的package包/类
@Override
public boolean zoomToFixing(double zoomLevel, int xPixel, int yPixel, Long zoomAnimationSpeed) {
zoomLevel = zoomLevel > mMapView.getMaxZoomLevel() ? mMapView.getMaxZoomLevel() : zoomLevel;
zoomLevel = zoomLevel < mMapView.getMinZoomLevel() ? mMapView.getMinZoomLevel() : zoomLevel;
double currentZoomLevel = mMapView.getZoomLevelDouble();
boolean canZoom = zoomLevel < currentZoomLevel && mMapView.canZoomOut() ||
zoomLevel > currentZoomLevel && mMapView.canZoomIn();
if (!canZoom) {
return false;
}
if (mMapView.mIsAnimating.getAndSet(true)) {
// TODO extend zoom (and return true)
return false;
}
for (MapListener mapListener: mMapView.mListners) {
mapListener.onZoom(new ZoomEvent(mMapView, zoomLevel));
}
mMapView.setMultiTouchScaleInitPoint(xPixel, yPixel);
mMapView.startAnimation();
float end = (float) Math.pow(2.0, zoomLevel - currentZoomLevel);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
ZoomAnimatorListener zoomAnimatorListener = new ZoomAnimatorListener(this);
ValueAnimator zoomToAnimator = ValueAnimator.ofFloat(1f, end);
zoomToAnimator.addListener(zoomAnimatorListener);
zoomToAnimator.addUpdateListener(zoomAnimatorListener);
if (zoomAnimationSpeed == null) {
zoomToAnimator.setDuration(Configuration.getInstance().getAnimationSpeedShort());
} else {
zoomToAnimator.setDuration(zoomAnimationSpeed);
}
mCurrentAnimator = zoomToAnimator;
zoomToAnimator.start();
return true;
}
mTargetZoomLevel = zoomLevel;
if (zoomLevel > currentZoomLevel)
mMapView.startAnimation(mZoomInAnimationOld);
else
mMapView.startAnimation(mZoomOutAnimationOld);
ScaleAnimation scaleAnimation;
scaleAnimation = new ScaleAnimation(
1f, end, //X
1f, end, //Y
Animation.RELATIVE_TO_SELF, 0.5f, //Pivot X
Animation.RELATIVE_TO_SELF, 0.5f); //Pivot Y
if (zoomAnimationSpeed == null) {
scaleAnimation.setDuration(Configuration.getInstance().getAnimationSpeedShort());
} else {
scaleAnimation.setDuration(zoomAnimationSpeed);
}
scaleAnimation.setAnimationListener(new ZoomAnimationListener(this));
return true;
}
示例5: setZoomLevel
import org.osmdroid.events.MapListener; //导入依赖的package包/类
/**
* @param aZoomLevel
* the zoom level bound by the tile source
* Used to be an int - is a double since 6.0
*/
double setZoomLevel(final double aZoomLevel) {
final double newZoomLevel = Math.max(getMinZoomLevel(), Math.min(getMaxZoomLevel(), aZoomLevel));
final double curZoomLevel = this.mZoomLevel;
if (newZoomLevel != curZoomLevel) {
if (mScroller!=null) //fix for edit mode in the IDE
mScroller.forceFinished(true);
mIsFlinging = false;
}
// Get our current center point
final IGeoPoint centerGeoPoint = getProjection().getCurrentCenter();
this.mZoomLevel = newZoomLevel;
setExpectedCenter(centerGeoPoint);
this.checkZoomButtons();
if (isLayoutOccurred()) {
getController().setCenter(centerGeoPoint);
// snap for all snappables
final Point snapPoint = new Point();
final Projection pj = getProjection();
if (this.getOverlayManager().onSnapToItem((int) mMultiTouchScaleInitPoint.x,
(int) mMultiTouchScaleInitPoint.y, snapPoint, this)) {
IGeoPoint geoPoint = pj.fromPixels(snapPoint.x, snapPoint.y, null, false);
getController().animateTo(geoPoint);
}
mTileProvider.rescaleCache(pj, newZoomLevel, curZoomLevel, getScreenRect(null));
pauseFling = true; // issue 269, pause fling during zoom changes
}
// do callback on listener
if (newZoomLevel != curZoomLevel) {
final ZoomEvent event = new ZoomEvent(this, newZoomLevel);
for (MapListener mapListener: mListners)
mapListener.onZoom(event);
}
invalidate();
return this.mZoomLevel;
}
示例6: setMapListener
import org.osmdroid.events.MapListener; //导入依赖的package包/类
@Deprecated
public void setMapListener(final MapListener ml) {
this.mListners.add(ml);
}
示例7: addMapListener
import org.osmdroid.events.MapListener; //导入依赖的package包/类
/**
* Just like the old setMapListener, except it supports more than one
* @since 6.0.0
* @param mapListener
*/
public void addMapListener(MapListener mapListener) {
this.mListners.add(mapListener);
}
示例8: removeMapListener
import org.osmdroid.events.MapListener; //导入依赖的package包/类
/**
* Removes a map listener
* @since 6.0.0
* @param mapListener
*/
public void removeMapListener(MapListener mapListener) {
this.mListners.remove(mapListener);
}