@Override public final void setOnMyLocationChangeListener(OnMyLocationChangeListener listener) { map.setOnMyLocationChangeListener(listener); }
private void setOnMyLocationChangedListener() { mGoogleMap.setOnMyLocationChangeListener(new OnMyLocationChangeListener() { @Override public void onMyLocationChange(Location loc) { float zoomLevel = mCurrentZoom; mCurrentLocation = loc; mGoogleMap.clear(); if(mDestinationLocation == null) { mDestinationLocation = new Location(loc); // Destination is not selected yet. Initialize destination mNaviInfo.initDestLocation(mDestinationLocation); // If there is pre-used destination, show it on map if(mNaviInfo.getDestLatitude() != 0 && mNaviInfo.getDestLongitude() != 0) { drawDestination(new LatLng(mNaviInfo.getDestLatitude(), mNaviInfo.getDestLongitude()), false); } } else { mNaviInfo.setCurLocation(loc); } if(!mIsInitialized) { zoomLevel = INITIAL_ZOOM_LEVEL; } else { zoomLevel = 0; } addMarkerOnMap(loc.getLatitude(), loc.getLongitude(), "I'm here", // title loc.getLatitude() + ", " + loc.getLongitude(), // snippet false, // draggable MARKER_DEFAULT, // marker zoomLevel, // 0 means keep current zoom level !mIsInitialized); // move camera only when it's first time if(mNaviInfo.getDestLatitude() == 0 && mNaviInfo.getDestLongitude() == 0) { // Destination is not set. Do nothing } else { drawDestination(new LatLng(mNaviInfo.getDestLatitude(), mNaviInfo.getDestLongitude()), false); } mIsInitialized = true; mUnitType = AppSettings.getUnitType(); StringBuilder sb = new StringBuilder(); sb.append(mNaviMode==NAVI_MODE_COMPASS?"compass":"direction"); sb.append(","); sb.append(mUnitType==UNIT_TYPE_METERS?"meters":"feet"); mFragmentListener.OnFragmentCallback(IFragmentListener.CALLBACK_MAP_UPDATE_NAVI_INFO, (int)mNaviInfo.getDistance(), (int)mNaviInfo.getAngle(), String.format("%.3f", mDestinationLocation.getLatitude()), String.format("%.3f", mDestinationLocation.getLongitude()), sb.toString()); } }); }
void setOnMyLocationChangeListener(OnMyLocationChangeListener listener);