Java Code Examples for com.google.android.gms.maps.model.MarkerOptions#visible()

The following examples show how to use com.google.android.gms.maps.model.MarkerOptions#visible() . 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: GoogleMapShapeConverter.java    From geopackage-android-map with MIT License 6 votes vote down vote up
/**
 * Add a list of LatLngs to the map
 *
 * @param map     google map
 * @param latLngs lat lngs
 * @return multi marker
 */
public static MultiMarker addLatLngsToMap(GoogleMap map, MultiLatLng latLngs) {
    MultiMarker multiMarker = new MultiMarker();
    for (LatLng latLng : latLngs.getLatLngs()) {
        MarkerOptions markerOptions = new MarkerOptions();
        if (latLngs.getMarkerOptions() != null) {
            markerOptions.icon(latLngs.getMarkerOptions().getIcon());
            markerOptions.anchor(latLngs.getMarkerOptions().getAnchorU(),
                    markerOptions.getAnchorV());
            markerOptions.draggable(latLngs.getMarkerOptions()
                    .isDraggable());
            markerOptions.visible(latLngs.getMarkerOptions().isVisible());
            markerOptions.zIndex(latLngs.getMarkerOptions().getZIndex());
        }
        Marker marker = addLatLngToMap(map, latLng, markerOptions);
        multiMarker.add(marker);
    }
    return multiMarker;
}
 
Example 2
Source File: GeoJsonPointStyle.java    From android-maps-utils with Apache License 2.0 6 votes vote down vote up
/**
 * Gets a new MarkerOptions object containing styles for the GeoJsonPoint
 *
 * @return new MarkerOptions object
 */
public MarkerOptions toMarkerOptions() {
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.alpha(mMarkerOptions.getAlpha());
    markerOptions.anchor(mMarkerOptions.getAnchorU(), mMarkerOptions.getAnchorV());
    markerOptions.draggable(mMarkerOptions.isDraggable());
    markerOptions.flat(mMarkerOptions.isFlat());
    markerOptions.icon(mMarkerOptions.getIcon());
    markerOptions.infoWindowAnchor(mMarkerOptions.getInfoWindowAnchorU(),
            mMarkerOptions.getInfoWindowAnchorV());
    markerOptions.rotation(mMarkerOptions.getRotation());
    markerOptions.snippet(mMarkerOptions.getSnippet());
    markerOptions.title(mMarkerOptions.getTitle());
    markerOptions.visible(mMarkerOptions.isVisible());
    markerOptions.zIndex(mMarkerOptions.getZIndex());
    return markerOptions;
}
 
Example 3
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 4
Source File: LocationMarkerCollection.java    From mage-android with Apache License 2.0 5 votes vote down vote up
@Override
public void add(MarkerOptions options, Pair<Location, User> pair) {
	Location location = pair.first;
	User user = pair.second;

	final Geometry g = location.getGeometry();
	if (g != null) {

		// one user has one location
		Marker marker = userIdToMarker.get(user.getId());
		if (marker != null) {
			markerIdToPair.remove(marker.getId());
			marker.remove();

			if (clickedAccuracyCircleUserId != null && clickedAccuracyCircleUserId.equals(user.getId())) {
				if (clickedAccuracyCircle != null) {
					clickedAccuracyCircle.remove();
					clickedAccuracyCircle = null;
				}
			}
		}

		options.visible(visible);

		marker = map.addMarker(options);
		userIdToMarker.put(user.getId(), marker);
		markerIdToPair.put(marker.getId(), pair);

		if (location.getTimestamp().after(latestLocationDate)) {
			latestLocationDate = location.getTimestamp();
		}
	}
}
 
Example 5
Source File: ObservationMarkerCollection.java    From mage-android with Apache License 2.0 5 votes vote down vote up
@Override
public void add(MarkerOptions options, Observation observation) {
    // If I got an observation that I already have remove it
    mapObservations.remove(observation.getId());

    // Add the new observation to the map and maintain it
    options.visible(visible);
    MapObservation mapObservation = mapObservationManager.addToMap(observation, options, visible);
    mapObservations.add(mapObservation);

    if (observation.getLastModified().after(latestObservationDate)) {
        latestObservationDate = observation.getLastModified();
    }
}
 
Example 6
Source File: MyHistoricalLocationMarkerCollection.java    From mage-android with Apache License 2.0 5 votes vote down vote up
@Override
public void add(MarkerOptions options, Pair<Location, User> pair) {
	Location location = pair.first;
	final Geometry gometry = location.getGeometry();

	if (gometry != null) {
		options.visible(visible);
		Marker marker = map.addMarker(options);
		markerIdToLocation.put(marker.getId(), pair);
		Marker oldMarker = locationIdToMarker.put(location.getId(), marker);
		if (oldMarker != null) {
			oldMarker.remove();
		}

		locationQueue.add(location);

		while (locationQueue.size() > LocationPushTask.Companion.getMinNumberOfLocationsToKeep()) {
			Location locationToRemove = locationQueue.poll();

			Marker markerToRemove = locationIdToMarker.remove(locationToRemove.getId());
			if (markerToRemove != null) {
				markerToRemove.remove();
				markerIdToLocation.remove(markerToRemove.getId());
			}
		}
	}
}
 
Example 7
Source File: MapObservationManager.java    From mage-android with Apache License 2.0 5 votes vote down vote up
/**
 * Add a shape marker to the map at the location.  A shape marker is a transparent icon for allowing shape info windows.
 *
 * @param latLng  lat lng location
 * @param visible visible state
 * @return shape marker
 */
public Marker addShapeMarker(LatLng latLng, boolean visible) {

    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.icon(BitmapDescriptorFactory.fromBitmap(Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)));
    markerOptions.visible(visible);
    markerOptions.anchor(0.5f, 0.5f);
    markerOptions.position(latLng);
    Marker marker = map.addMarker(markerOptions);

    return marker;
}
 
Example 8
Source File: MapObservationManager.java    From mage-android with Apache License 2.0 3 votes vote down vote up
/**
 * Prepare the marker options for an observation point
 *
 * @param observation observation
 * @param visible     visible flag
 * @return marker options
 */
private MarkerOptions getMarkerOptions(Observation observation, boolean visible) {
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.icon(ObservationBitmapFactory.bitmapDescriptor(context, observation));
    markerOptions.visible(visible);
    return markerOptions;
}