본문
180910(월) - Google Maps (Events)
Google Maps
Events
Map click / long click events
Disabling click events in lite mode
- lite mode only
MapView view;
...
view.setClickable(false);
MapFragment fragment;
...
fragment.getView().setClickable(false);
Camera change events
- modeled as a camera looking down on a flat plane
- camera zoom level, view port, perspective 변경 가능
public class MyCameraActivity extends FragmentActivity implements
OnCameraMoveStartedListener,
OnCameraMoveListener,
OnCameraMoveCanceledListener,
OnCameraIdleListener,
OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_camera);
SupportMapFragment mapFragment =
(SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap map) {
mMap = map;
mMap.setOnCameraIdleListener(this);
mMap.setOnCameraMoveStartedListener(this);
mMap.setOnCameraMoveListener(this);
mMap.setOnCameraMoveCanceledListener(this);
// Show Sydney on the map.
mMap.moveCamera(CameraUpdateFactory
.newLatLngZoom(new LatLng(-33.87365, 151.20689), 10));
}
@Override
public void onCameraMoveStarted(int reason) {
if (reason == OnCameraMoveStartedListener.REASON_GESTURE) {
Toast.makeText(this, "The user gestured on the map.",
Toast.LENGTH_SHORT).show();
} else if (reason == OnCameraMoveStartedListener
.REASON_API_ANIMATION) {
Toast.makeText(this, "The user tapped something on the map.",
Toast.LENGTH_SHORT).show();
} else if (reason == OnCameraMoveStartedListener
.REASON_DEVELOPER_ANIMATION) {
Toast.makeText(this, "The app moved the camera.",
Toast.LENGTH_SHORT).show();
}
}
@Override
public void onCameraMove() {
Toast.makeText(this, "The camera is moving.",
Toast.LENGTH_SHORT).show();
}
@Override
public void onCameraMoveCanceled() {
Toast.makeText(this, "Camera movement canceled.",
Toast.LENGTH_SHORT).show();
}
@Override
public void onCameraIdle() {
Toast.makeText(this, "The camera has stopped moving.",
Toast.LENGTH_SHORT).show();
}
}
- onCameraMoveStarted()
reason을 callback으로 받음
・ REASON_GESTURE
・ REASON_API_ANIMATION
tapping zoom button, My Location, marker
・ REASON_EVELOPER_ANIMATION
initiated camera movement
- onCameraMove()
invoked multiple times
- onCameraIdle()
stop camera moving & stopped user interacting
- onCameraMoveCanceled()
camera movement has been interrupted
- 명시적으로 GoogleMap.stopAnimation()
call하면, canceled()만 불리고, started는 not invoked
Deprecation notice : OnCameraChangeListener
is deprecated
Events on businesses and other POI
- businesses and other points of interest.
Indoor map events
- GoogleMap.getFocusedBuilding()
- IndoorBuilding.getActiveLevelIndex()
.
IndoorBuilding building = mMap.getFocusedBuilding();
if (building == null) {
return null;
}
return building.getLevels().get(building.getActiveLevelIndex());
Hint : street level로 돌아가려면, IndoorBuilding.getDefaultLevelIndex(), IndoorLevel.activate()
.
Marker, info window, shape and overlay
- 만약 multiple overlays or shapes가 overlaid 되어 있다면, click cycle은
1. cluster of markers
2. other clickable overlays or shapes, based on their z-index values
즉, z-index values 밑으로는 click is not passed.
marker z-index and click events.
Location events
- My Location button
GoogleMap.OnMyLocationButtonClickListener
.
- My Location blue dot
'Mobile > Google Maps' 카테고리의 다른 글
180911(화) - Google Maps (Location data) (0) | 2018.09.11 |
---|---|
180910(월) - Google Maps (Camera and View) (0) | 2018.09.10 |
180910(월) - Google Maps (Controls and Gestures) (0) | 2018.09.10 |
180910(월) - Google Maps (Style Reference) (0) | 2018.09.10 |
180907(금) - Google Maps (Hiding Map Features with Styilng) (0) | 2018.09.07 |
댓글