@Override public boolean onTap(LatLong tapLatLong, Point layerXY, Point tapXY) { if (contains(tapXY, mapView.getMapViewProjection())) { Toast.makeText(OverlayMapViewer.this, "Polyline tap\n" + tapLatLong, Toast.LENGTH_SHORT).show(); return true; } return false; } };
@Override public boolean onTap(LatLong tapLatLong, Point layerXY, Point tapXY) { // GroupLayer does not have a position, layerXY is null layerXY = mapView.getMapViewProjection().toPixels(getPosition()); if (contains(layerXY, tapXY)) { Toast.makeText(PoiSearchViewer.this, pointOfInterest.getName(), Toast.LENGTH_SHORT).show(); return true; } return false; } }
@Override public boolean onSingleTapConfirmed(MotionEvent e) { Point tapXY = new Point(e.getX(), e.getY()); LatLong tapLatLong = this.mapView.getMapViewProjection().fromPixels(tapXY.x, tapXY.y); if (tapLatLong != null) { for (int i = this.mapView.getLayerManager().getLayers().size() - 1; i >= 0; --i) { Layer layer = this.mapView.getLayerManager().getLayers().get(i); Point layerXY = this.mapView.getMapViewProjection().toPixels(layer.getPosition()); if (layer.onTap(tapLatLong, layerXY, tapXY)) { return true; } } } return false; }
@Override public void onLongPress(MotionEvent e) { // Normal or quick scale (no long press) if (!this.isInScale && !this.isInDoubleTap) { Point tapXY = new Point(e.getX(), e.getY()); LatLong tapLatLong = this.mapView.getMapViewProjection().fromPixels(tapXY.x, tapXY.y); if (tapLatLong != null) { for (int i = this.mapView.getLayerManager().getLayers().size() - 1; i >= 0; --i) { Layer layer = this.mapView.getLayerManager().getLayers().get(i); Point layerXY = this.mapView.getMapViewProjection().toPixels(layer.getPosition()); if (layer.onLongPress(tapLatLong, layerXY, tapXY)) { break; } } } } }
double moveHorizontal = (center.x - e.getX()) / Math.pow(2, zoomLevelDiff); double moveVertical = (center.y - e.getY()) / Math.pow(2, zoomLevelDiff); LatLong pivot = this.mapView.getMapViewProjection().fromPixels(e.getX(), e.getY()); if (pivot != null) { this.mapView.onMoveEvent();
@Override public boolean onScaleBegin(ScaleGestureDetector detector) { if (!scaleEnabled) { return false; } this.isInScale = true; this.scaleFactorCumulative = 1f; // Quick scale (no pivot) if (this.isInDoubleTap) { this.mapView.onZoomEvent(); this.pivot = null; } else { this.mapView.onMoveEvent(); this.mapView.onZoomEvent(); this.focusX = detector.getFocusX(); this.focusY = detector.getFocusY(); this.pivot = this.mapView.getMapViewProjection().fromPixels(focusX, focusY); } return true; }
Point layerXY = this.mapView.getMapViewProjection().toPixels(pointOfInterest.position); if (layerXY.distance(tapXY) > touchRadius) { continue;