com.google.android.gms.maps.model.Marker Java Examples

The following examples show how to use com.google.android.gms.maps.model.Marker. 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: MovingMarkerActivity.java    From Airbnb-Android-Google-Map-View with MIT License 6 votes vote down vote up
/**
   * Highlight the marker by marker.
   */
  private void highLightMarker(Marker marker) {

/*
      for (Marker foundMarker : this.markers) {
	if (!foundMarker.equals(marker)) {
		foundMarker.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
	} else {
		foundMarker.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE));
		foundMarker.showInfoWindow();
	}
}
*/
      marker.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE));
      //  marker.showInfoWindow();
      //marker.remove();
      //Utils.bounceMarker(googleMap, marker);

      this.selectedMarker = marker;
  }
 
Example #2
Source File: ObservationMarkerCollection.java    From mage-android with Apache License 2.0 6 votes vote down vote up
@Override
 public void refreshMarkerIcons(Filter<Temporal> filter) {
     for (MapMarkerObservation mapMarkerObservation : mapObservations.getMarkers()) {
         Marker marker = mapMarkerObservation.getMarker();
         Observation observation = mapMarkerObservation.getObservation();
if (observation != null) {
             if (filter != null && !filter.passesFilter(observation)) {
                 this.remove(observation);
             } else {
                 boolean showWindow = marker.isInfoWindowShown();
                 // make sure to set the Anchor after this call as well, because the size of the icon might have changed
                 marker.setIcon(ObservationBitmapFactory.bitmapDescriptor(context, observation));
                 marker.setAnchor(0.5f, 1.0f);
                 if (showWindow) {
                     marker.showInfoWindow();
                 }
             }
         }
     }
 }
 
Example #3
Source File: DriverHome.java    From UberClone with MIT License 6 votes vote down vote up
private void rotateMarket(Marker marker, final float degrees, GoogleMap mMap){
    final Handler handler=new Handler();
    long start= SystemClock.uptimeMillis();
    final float startRotation=currentLocationMarket.getRotation();
    final long duration=1500;

    final Interpolator interpolator=new LinearInterpolator();
    handler.post(new Runnable() {
        @Override
        public void run() {
            long elapsed=SystemClock.uptimeMillis();
            float t=interpolator.getInterpolation((float)elapsed/duration);
            float rot=t*degrees+(1-t)*startRotation;

            currentLocationMarket.setRotation(-rot>180?rot/2:rot);
            if (t<1.0){
                handler.postDelayed(this, 16);
            }
        }
    });
}
 
Example #4
Source File: MapViewPager.java    From MapViewPager with Apache License 2.0 6 votes vote down vote up
private GoogleMap.OnMarkerClickListener createMarkerClickListenerSingle(final Adapter adapter) {
    return new GoogleMap.OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(Marker marker) {
            for (int i = 0; i < adapter.getCount(); i++) {
                CameraPosition cp = adapter.getCameraPosition(i);
                if (cp != null && cp.target != null
                        && cp.target.latitude == marker.getPosition().latitude
                        && cp.target.longitude == marker.getPosition().longitude) {
                    viewPager.setCurrentItem(i);
                    marker.showInfoWindow();
                    return true;
                }
            }
            return false;
        }
    };
}
 
Example #5
Source File: LocationPickerActivity.java    From LocationPicker with MIT License 6 votes vote down vote up
private void addMarker() {

        LatLng coordinate = new LatLng(mLatitude, mLongitude);
        if (mMap != null) {
            MarkerOptions markerOptions;
            try {
                mMap.clear();
                imgSearch.setText("" + userAddress);

                markerOptions = new MarkerOptions().position(coordinate).title(userAddress).icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_place_red_800_24dp));
                CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(coordinate, 14);
                mMap.animateCamera(cameraUpdate);
                mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);

                Marker marker = mMap.addMarker(markerOptions);
                marker.showInfoWindow();
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }

    }
 
Example #6
Source File: MarkerManager.java    From android-custom-markers with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onMarkerClick(Marker marker) {

    if (lastSelected != null) {
        lastSelected.setSelected(false);
    }

    final T item = markerCache.get(marker);

    if (item != null) {
        item.setSelected(true);
        lastSelected = item;
    }

    return onMarkerClickListener != null
            && onMarkerClickListener.onMarkerClick(markerCache.get(marker));
}
 
Example #7
Source File: VehicleAction.java    From Companion-For-PUBG-Android with MIT License 5 votes vote down vote up
@Override
protected void onToggleAction() {
    if (shouldShow()) {
        for (final LatLng latLng : this.vehicleSpawns) {
            final MarkerOptions markerOptions = createMarkerOptions();
            markerOptions.position(latLng);
            this.vehicleMarkers.add(this.mapController.addMarker(markerOptions));
        }
    } else {
        for (final Marker marker : this.vehicleMarkers) {
            marker.remove();
        }
        this.vehicleMarkers.clear();
    }
}
 
Example #8
Source File: GoogleMapShapeConverter.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * Add the list of points as markers
 *
 * @param map                 google map
 * @param points              points
 * @param customMarkerOptions custom marker options
 * @param ignoreIdenticalEnds ignore identical ends flag
 * @return list of markers
 */
public List<Marker> addPointsToMapAsMarkers(GoogleMap map,
                                            List<LatLng> points, MarkerOptions customMarkerOptions,
                                            boolean ignoreIdenticalEnds) {

    List<Marker> markers = new ArrayList<Marker>();
    for (int i = 0; i < points.size(); i++) {
        LatLng latLng = points.get(i);

        if (points.size() > 1 && i + 1 == points.size() && ignoreIdenticalEnds) {
            LatLng firstLatLng = points.get(0);
            if (latLng.latitude == firstLatLng.latitude
                    && latLng.longitude == firstLatLng.longitude) {
                break;
            }
        }

        MarkerOptions markerOptions = new MarkerOptions();
        if (customMarkerOptions != null) {
            markerOptions.icon(customMarkerOptions.getIcon());
            markerOptions.anchor(customMarkerOptions.getAnchorU(),
                    customMarkerOptions.getAnchorV());
            markerOptions.draggable(customMarkerOptions.isDraggable());
            markerOptions.visible(customMarkerOptions.isVisible());
            markerOptions.zIndex(customMarkerOptions.getZIndex());
        }
        Marker marker = addLatLngToMap(map, latLng, markerOptions);
        markers.add(marker);
    }
    return markers;
}
 
Example #9
Source File: ClusterRenderer.java    From google-maps-clustering with Apache License 2.0 5 votes vote down vote up
private void animateMarkerToLocation(@NonNull final Marker marker, @NonNull LatLng targetLocation,
                                     final boolean removeAfter) {
    ObjectAnimator objectAnimator = ObjectAnimator.ofObject(marker, "position",
            new LatLngTypeEvaluator(), targetLocation);
    objectAnimator.setInterpolator(new FastOutSlowInInterpolator());
    objectAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (removeAfter) {
                marker.remove();
            }
        }
    });
    objectAnimator.start();
}
 
Example #10
Source File: BarometerNetworkActivity.java    From PressureNet with GNU General Public License v3.0 5 votes vote down vote up
private void addConditionMarkersToMap() {
	try {
		for(MarkerOptions options : liveMarkerOptions) {
			Marker marker = mMap.addMarker(options);	
		}	
	} catch(ConcurrentModificationException cme) {
		log("concurrentmodificationexception adding markers to map " + cme.getMessage());
	}
	
}
 
Example #11
Source File: GoogleMapShape.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * Expand the bounding box by the markers
 *
 * @param boundingBox bounding box
 * @param markers     list of markers
 */
private void expandBoundingBoxMarkers(BoundingBox boundingBox,
                                      List<Marker> markers) {
    for (Marker marker : markers) {
        expandBoundingBox(boundingBox, marker.getPosition());
    }
}
 
Example #12
Source File: GglMapAiLineManager.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public void addSmallMakerByMap(Marker marker1, Marker marker2) {
    MapPointLatLng mpl2 = (MapPointLatLng) marker2.getTag();
    LatLng[] latLng = this.mapCalcAngle.getLineLatLngInterval(marker1.getPosition(), marker2.getPosition(), 3);
    float[] angleArray = new float[]{mpl2.showAngle, mpl2.showAngle};
    for (int i = 0; i < latLng.length; i++) {
        MapPointLatLng mpl = new MapPointLatLng();
        mpl.isSelect = true;
        mpl.setAngle(angleArray[i]);
        Marker mMarker = this.googleMap.addMarker(new MarkerOptions().position(latLng[i]).icon(this.gdCustemMarkerView.createPointWithSmallArrow(this.context, R.drawable.x8_ai_line_point_small1, mpl.showAngle, true)).anchor(0.5f, 0.5f).draggable(false));
        mMarker.setTag(mpl);
        mMarker.setFlat(true);
        this.arrowMarkerList.add(mMarker);
    }
}
 
Example #13
Source File: PolygonMarkers.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void delete(Marker marker) {
    if (markers.remove(marker)) {
        marker.remove();
        update();
    }
}
 
Example #14
Source File: NativeGoogleMapFragment.java    From AirMapView with Apache License 2.0 5 votes vote down vote up
@Override public void setOnMarkerClickListener(final OnMapMarkerClickListener listener) {
  googleMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
    @Override public boolean onMarkerClick(Marker marker) {
      AirMapMarker<?> airMarker = markers.get(marker);
      if (airMarker != null) {
        return listener.onMapMarkerClick(airMarker);
      }
      return false;
    }
  });
}
 
Example #15
Source File: EmergencyInteractorImpl.java    From Saude-no-Mapa with MIT License 5 votes vote down vote up
@Override
public void animateCameraToAllEstablishments(GoogleMap mMap) {
    if (mMap != null) {
        LatLngBounds.Builder builder = new LatLngBounds.Builder();
        for (Marker marker : mDeviceMarkerHash.values()) {
            builder.include(marker.getPosition());
        }
        LatLngBounds bounds = builder.build();

        mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 100));
    }
}
 
Example #16
Source File: GeofieldFragment.java    From mobile-android-survey-app with MIT License 5 votes vote down vote up
@Override
public void onMarkerDragEnd(Marker marker) {
    if (marker.getPosition() != null) {
        Log.i(this, "onMarkerDragEnd %f,%f", marker.getPosition().latitude, marker.getPosition().longitude);
        setLocation(marker.getPosition().latitude, marker.getPosition().longitude, false);
    }
}
 
Example #17
Source File: EarthquakeMapFragment.java    From Wrox-ProfessionalAndroid-4E with Apache License 2.0 5 votes vote down vote up
public void setEarthquakeMarkers(List<Earthquake> earthquakes) {
  updateFromPreferences();

  mEarthquakes = earthquakes;

  if (mMap == null || earthquakes == null) return;

  Map<String, Earthquake> newEarthquakes = new HashMap<>();

  // Add Markers for each earthquake above the user threshold.
  for (Earthquake earthquake : earthquakes) {
    if (earthquake.getMagnitude() >= mMinimumMagnitude) {
      newEarthquakes.put(earthquake.getId(), earthquake);
      if (!mMarkers.containsKey(earthquake.getId())) {
        Location location = earthquake.getLocation();
        Marker marker = mMap.addMarker(
          new MarkerOptions()
            .position(new LatLng(location.getLatitude(),
              location.getLongitude()))
            .title("M:" + earthquake.getMagnitude()));
        mMarkers.put(earthquake.getId(), marker);
      }
    }
  }

  // Remove any Markers representing earthquakes that should no longer
  // be displayed.
  for (Iterator<String> iterator = mMarkers.keySet().iterator();
       iterator.hasNext();) {
    String earthquakeID = iterator.next();
    if (!newEarthquakes.containsKey(earthquakeID)) {
      mMarkers.get(earthquakeID).remove();
      iterator.remove();
    }
  }
}
 
Example #18
Source File: GglMapAiLineManager.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public void addInterestByDevice(AckGetAiLinePoint point) {
    MapPointLatLng mp = new MapPointLatLng();
    mp.isIntertestPoint = true;
    mp.isMapPoint = true;
    mp.nPos = this.interestMarkerList.size() + 1;
    mp.altitude = (float) point.getAltitudePOI();
    mp.latitude = point.getLatitudePOI();
    mp.longitude = point.getLongitudePOI();
    Marker interestMarker = addInterestMarker(new LatLng(mp.latitude, mp.longitude), mp.altitude, mp);
    interestMarker.setTag(mp);
    interestMarker.setDraggable(true);
    this.interestMarkerList.add(interestMarker);
}
 
Example #19
Source File: TagsDemoActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onMarkerClick(final Marker marker) {
    onClick((CustomTag) marker.getTag());
    // We return true to indicate that we have consumed the event and that we do not wish
    // for the default behavior to occur (which is for the camera to move such that the
    // marker is centered and for the marker's info window to open, if it has one).
    return true;
}
 
Example #20
Source File: PolygonHoleMarkers.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void delete(Marker marker) {
    if (markers.remove(marker)) {
        marker.remove();
        parentPolygon.update();
    }
}
 
Example #21
Source File: MarkerDemoActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
@Override
public View getInfoContents(Marker marker) {
    if (mOptions.getCheckedRadioButtonId() != R.id.custom_info_contents) {
        // This means that the default info contents will be used.
        return null;
    }
    render(marker, mContents);
    return mContents;
}
 
Example #22
Source File: MyHistoricalLocationMarkerCollection.java    From mage-android with Apache License 2.0 5 votes vote down vote up
@Override
public void setVisibility(boolean visible) {
	if (this.visible == visible)
		return;

	this.visible = visible;
	for (Marker m : locationIdToMarker.values()) {
		m.setVisible(visible);
	}
}
 
Example #23
Source File: MarkerManager.java    From android-maps-utils with Apache License 2.0 5 votes vote down vote up
@Override
public void onInfoWindowLongClick(Marker marker) {
    Collection collection = mAllObjects.get(marker);
    if (collection != null && collection.mInfoWindowLongClickListener != null) {
        collection.mInfoWindowLongClickListener.onInfoWindowLongClick(marker);
    }
}
 
Example #24
Source File: LocationMarkerCollection.java    From mage-android with Apache License 2.0 5 votes vote down vote up
@Override
public void refresh(Pair<Location, User> pair) {
	// TODO Maybe a different generic for this case
	// TODO implementing room might help solve this problem
	// In this case I know just the user is coming in
	// grab the location based on that
	User user = pair.second;
	Marker marker = userIdToMarker.get(pair.second.getId());

	if (marker != null) {
		Location location = markerIdToPair.get(marker.getId()).first;
		markerIdToPair.put(marker.getId(), new Pair(location, user));
		marker.setIcon(LocationBitmapFactory.bitmapDescriptor(context, location, user));
	}
}
 
Example #25
Source File: GglMapAiLineManager.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public void removeLinePoint(LatLng homeLocation) {
    MapPointLatLng removeMapPointLatLng = null;
    for (MapPointLatLng mMapPointLatLng : this.mMapPointList) {
        LatLng mLatLng = this.mSelectMarker.getPosition();
        if (mLatLng.longitude == mMapPointLatLng.longitude && mLatLng.latitude == mMapPointLatLng.latitude) {
            removeMapPointLatLng = mMapPointLatLng;
            break;
        }
    }
    if (removeMapPointLatLng != null) {
        this.mMapPointList.remove(removeMapPointLatLng);
    }
    for (Marker marker : this.mMarkerList) {
        if (this.mSelectMarker == marker) {
            break;
        }
    }
    this.mMarkerList.remove(this.mSelectMarker);
    this.mSelectMarker.remove();
    int i = 0;
    for (Marker marker2 : this.mMarkerList) {
        i++;
        MapPointLatLng p = (MapPointLatLng) marker2.getTag();
        p.nPos = i;
        changePointMarker(marker2, p, false);
    }
    drawPointLine(homeLocation);
    this.mSelectMarker = null;
    this.lineMarkerSelectListener.onMarkerSizeChange(this.mMarkerList.size());
}
 
Example #26
Source File: BarometerNetworkActivity.java    From PressureNet with GNU General Public License v3.0 5 votes vote down vote up
private void addIcon(IconGenerator iconFactory, String text, LatLng position) {
    MarkerOptions markerOptions = new MarkerOptions().
            icon(BitmapDescriptorFactory.fromBitmap(iconFactory.makeIcon(text))).
            position(position).
            anchor(iconFactory.getAnchorU(), iconFactory.getAnchorV());

    Marker addedTemp = mMap.addMarker(markerOptions);
    
    //log("added temp icon");
}
 
Example #27
Source File: GglMapAiLineManager.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public List<MapPointLatLng> getInterestPointList() {
    List<MapPointLatLng> list = new ArrayList();
    for (int i = 0; i < this.interestMarkerList.size(); i++) {
        list.add((MapPointLatLng) ((Marker) this.interestMarkerList.get(i)).getTag());
    }
    return list;
}
 
Example #28
Source File: Clusterkraf.java    From clusterkraf with Apache License 2.0 5 votes vote down vote up
/**
 * @see com.google.android.gms.maps.GoogleMap.OnInfoWindowClickListener#
 *      onInfoWindowClick(com.google.android.gms.maps.model.Marker)
 */
@Override
public void onInfoWindowClick(Marker marker) {
	Clusterkraf clusterkraf = clusterkrafRef.get();
	if (clusterkraf != null) {
		boolean handled = false;
		ClusterPoint clusterPoint = clusterkraf.currentClusterPointsByMarker.get(marker);
		OnInfoWindowClickDownstreamListener downstreamListener = clusterkraf.options.getOnInfoWindowClickDownstreamListener();
		if (downstreamListener != null) {
			handled = downstreamListener.onInfoWindowClick(marker, clusterPoint);
		}
		if (handled == false && clusterPoint != null) {
			if (clusterPoint.size() > 1) {
				switch(clusterkraf.options.getClusterInfoWindowClickBehavior()) {
					case ZOOM_TO_BOUNDS:
						clusterkraf.zoomToBounds(clusterPoint);
						break;
					case HIDE_INFO_WINDOW:
						marker.hideInfoWindow();
						break;
					case NO_OP:
						// no-op
						break;
				}
			} else {
				switch(clusterkraf.options.getSinglePointInfoWindowClickBehavior()) {
					case HIDE_INFO_WINDOW:
						marker.hideInfoWindow();
						break;
					case NO_OP:
						// no-op
						break;
				}
			}
		}

	}

}
 
Example #29
Source File: NativeGoogleMapFragment.java    From AirMapView with Apache License 2.0 5 votes vote down vote up
@Override public void setOnInfoWindowClickListener(final OnInfoWindowClickListener listener) {
  googleMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
    @Override public void onInfoWindowClick(Marker marker) {
      AirMapMarker<?> airMarker = markers.get(marker);
      if (airMarker != null) {
        listener.onInfoWindowClick(airMarker);
      }
    }
  });
}
 
Example #30
Source File: Home.java    From UberClone with MIT License 5 votes vote down vote up
@Override
public void onInfoWindowClick(Marker marker) {
    if(!marker.getTitle().equals("You")){
        Intent intent=new Intent(Home.this, CallDriver.class);
        String ID= marker.getSnippet().replace("Driver ID: ", "");
        intent.putExtra("driverID", ID);
        intent.putExtra("lat", currentLat);
        intent.putExtra("lng", currentLng);
        startActivity(intent);
    }
}