Java Code Examples for com.google.android.gms.maps.GoogleMap#setOnMarkerClickListener()

The following examples show how to use com.google.android.gms.maps.GoogleMap#setOnMarkerClickListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GoogleMapsMapAdapter.java    From ground-android with Apache License 2.0 6 votes vote down vote up
public GoogleMapsMapAdapter(GoogleMap map, Context context, MarkerIconFactory markerIconFactory) {
  this.map = map;
  this.context = context;
  this.markerIconFactory = markerIconFactory;
  map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
  UiSettings uiSettings = map.getUiSettings();
  uiSettings.setRotateGesturesEnabled(false);
  uiSettings.setTiltGesturesEnabled(false);
  uiSettings.setMyLocationButtonEnabled(false);
  uiSettings.setMapToolbarEnabled(false);
  uiSettings.setCompassEnabled(false);
  uiSettings.setIndoorLevelPickerEnabled(false);
  map.setOnMarkerClickListener(this::onMarkerClick);
  map.setOnCameraIdleListener(this::onCameraIdle);
  map.setOnCameraMoveStartedListener(this::onCameraMoveStarted);
  map.setOnCameraMoveListener(this::onCameraMove);
  onCameraMove();
}
 
Example 2
Source File: ExploreFragment.java    From rox-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    this.googleMap = googleMap;
    googleMap.getUiSettings().setMapToolbarEnabled(false);
    googleMap.getUiSettings().setMyLocationButtonEnabled(false);
    LatLng latLng = new LatLng(
            PreferenceManager.getDefaultSharedPreferences(getActivity()).getFloat(getString(R.string.last_map_location_lat_key), 0f),
            PreferenceManager.getDefaultSharedPreferences(getActivity()).getFloat(getString(R.string.last_map_location_lng_key), 0f));
    googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng,
            PreferenceManager.getDefaultSharedPreferences(getActivity()).getFloat(getString(R.string.last_map_zoom_key), 0f)));
    googleMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(Marker marker) {
            int position = currentMarkers.indexOf(marker);
            viewPager.setCurrentItem(position, true);
            return false;
        }
    });
    if (shouldRestoreCurrentLocationInMap) showCurrentLocationInMap();
    if (shouldRestoreRecommendationsInMap) restoreRecommendationsInMap();
    if (shouldRestorePois) restorePoisInMap();
}
 
Example 3
Source File: Clusterkraf.java    From clusterkraf with Apache License 2.0 6 votes vote down vote up
/**
 * Construct a Clusterkraf instance to manage your map with customized
 * options and a list of points
 * 
 * @param map
 *            The GoogleMap to be managed by Clusterkraf
 * @param options
 *            Customized options
 */
public Clusterkraf(GoogleMap map, Options options, ArrayList<InputPoint> points) {
	this.mapRef = new WeakReference<GoogleMap>(map);
	this.options = options;
	this.innerCallbackListener = new InnerCallbackListener(this);
	this.transitionsAnimation = new ClusterTransitionsAnimation(map, options, innerCallbackListener);

	if (points != null) {
		this.points.addAll(points);
	}

	if (map != null) {
		map.setOnCameraChangeListener(innerCallbackListener.clusteringOnCameraChangeListener);
		map.setOnMarkerClickListener(innerCallbackListener);
		map.setOnInfoWindowClickListener(innerCallbackListener);
           map.setInfoWindowAdapter(innerCallbackListener);
	}

	showAllClusters();
}
 
Example 4
Source File: DetailClusterManager.java    From animation-samples with Apache License 2.0 5 votes vote down vote up
public DetailClusterManager(
        @NonNull Context context,
        @NonNull GoogleMap map,
        @NonNull OnClusterItemClickListener<Detail> onClusterItemClickListener,
        @NonNull GoogleMap.OnMapClickListener onMapClickListener,
        @NonNull OnCameraPositionUpdateListener onCameraPositionUpdateListener) {
    super(context, map, new NoEmptyInfoWindowMarkerManager(context, map));
    map.setOnInfoWindowClickListener(this);
    map.setOnMarkerClickListener(this);
    setRenderer(new DetailMarkerRenderer(context, map, this));
    mOnCameraPositionUpdateListener = onCameraPositionUpdateListener;
    map.setOnMapClickListener(onMapClickListener);
    setOnClusterItemClickListener(onClusterItemClickListener);
}
 
Example 5
Source File: MainActivity.java    From PokeFaker with MIT License 5 votes vote down vote up
private void setMap(GoogleMap map) {
    float density = getResources().getDisplayMetrics().density;
    map.setPadding(0, ((int) (82* density)), 0, 0);
    map.setOnMapClickListener(this);
    map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    map.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(Marker marker) {
            return true;
        }
    });
}
 
Example 6
Source File: SaveStateDemoActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onMapReady(GoogleMap map) {
    MarkerOptions markerOptions = new MarkerOptions()
            .position(mMarkerPosition)
            .icon(BitmapDescriptorFactory.defaultMarker(mMarkerInfo.mHue))
            .draggable(true);
    map.addMarker(markerOptions);
    map.setOnMarkerDragListener(this);
    map.setOnMarkerClickListener(this);

    if (mMoveCameraToMarker) {
        map.animateCamera(CameraUpdateFactory.newLatLng(mMarkerPosition));
    }
}
 
Example 7
Source File: PPTGoogleMapManager.java    From react-native-maps with MIT License 4 votes vote down vote up
/**
 * Event handler for when map is ready to receive update parameters.
 *
 * @param googleMap
 */
@Override
public void onMapReady(GoogleMap googleMap) {

    // Clear previous map if already there
    googleMap.clear();

    UiSettings settings = googleMap.getUiSettings();

    // Set location based flags
    if (locationManager != null) {
        settings.setMyLocationButtonEnabled(this.myLocationButton);
        googleMap.setMyLocationEnabled(this.showsUserLocation);
    }

    // Set all other flags
    settings.setScrollGesturesEnabled(this.scrollGestures);
    settings.setZoomGesturesEnabled(this.zoomGestures);
    settings.setTiltGesturesEnabled(this.tiltGestures);
    settings.setRotateGesturesEnabled(this.rotateGestures);
    settings.setCompassEnabled(this.compassButton);

    // Update the camera position
    if (cameraUpdate != null) {
        googleMap.moveCamera(cameraUpdate);
    }

    // Add the markers
    addMapMarkers(googleMap);
    googleMap.setOnMarkerClickListener(this);

    // Attach the event handlers
    if (firstMapReady) {
        googleMap.setOnCameraChangeListener(this);
        googleMap.setOnMapClickListener(this);
        googleMap.setOnMapLongClickListener(this);
        googleMap.setOnMarkerDragListener(this);
        googleMap.setOnMyLocationButtonClickListener(this);

        firstMapReady = false;
    }
}