Java Code Examples for com.google.android.gms.maps.model.Marker#setVisible()

The following examples show how to use com.google.android.gms.maps.model.Marker#setVisible() . 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: VPNFragment.java    From android with GNU General Public License v3.0 6 votes vote down vote up
private void processServers() {
    Marker[] markers = mMarkers.keySet().toArray(new Marker[mMarkers.size()]);
    for (int i = 0; i < mServers.size(); i++) {
        Server server = mServers.get(i);
        if (server.getCoordinates() != null && server.countryCode != null && server.countryCode.equals(mDetectedCountry)) {
            mCurrentLocation = server.getCoordinates();

            for (Marker marker : markers) {
                if (marker.getPosition().equals(mCurrentLocation)) {
                    marker.setVisible(false);
                } else {
                    marker.setVisible(true);
                }
            }
        }
    }
}
 
Example 2
Source File: PolygonHoleMarkers.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setVisibleMarkers(boolean visible) {
    for (Marker marker : markers) {
        marker.setVisible(visible);
    }
}
 
Example 3
Source File: PolygonMarkers.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setVisible(boolean visible) {
    if (polygon != null) {
        polygon.setVisible(visible);
    }
    for (Marker marker : markers) {
        marker.setVisible(visible);
    }
    for (PolygonHoleMarkers hole : holes) {
        hole.setVisible(visible);
    }
}
 
Example 4
Source File: PolygonMarkers.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setVisibleMarkers(boolean visible) {
    for (Marker marker : markers) {
        marker.setVisible(visible);
    }
    for (PolygonHoleMarkers hole : holes) {
        hole.setVisibleMarkers(visible);
    }
}
 
Example 5
Source File: PolylineMarkers.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setVisibleMarkers(boolean visible) {
    for (Marker marker : markers) {
        marker.setVisible(visible);
    }
}
 
Example 6
Source File: MultiMarker.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setVisibleMarkers(boolean visible) {
    for (Marker marker : markers) {
        marker.setVisible(visible);
    }
}
 
Example 7
Source File: NearbyLocationActivity.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
@Override
    public void onLocationChanged(Location location) {
        Log.d("OnLocationChanged", "here!!!!!!");
//        mLastLocation = location;
        if (initialize == 0) {
            mLastLocation = location;
            LatLng myCurrentLocation = new LatLng(mLastLocation.getLatitude(), mLastLocation.getLongitude());
            mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(myCurrentLocation, 13), 3000, null);

            List<Shop> shopWithinRange = new ArrayList<>();
            for (int i = 0; i < shopList.size(); i++) {
                LatLng shopLocation = new LatLng(shopList.get(i).getLatitude(), shopList.get(i).getLongitude());
                Marker shopLocationMarker = mMap.addMarker(new MarkerOptions().position(shopLocation)
                        .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
                shopLocationMarker.setVisible(false);
                Location target = new Location("target");
                target.setLatitude(shopList.get(i).getLatitude());
                target.setLongitude(shopList.get(i).getLongitude());
                Log.d("before_compare_location", "" + mLastLocation.distanceTo(target));
                if (mLastLocation.distanceTo(target) < 4000) {
                    shopLocationMarker.setVisible(true);
                    shopWithinRange.add(shopList.get(i));
                }
            }
            bottomPanel.setVisibility(View.GONE);
            initialize = 1;
        }
    }
 
Example 8
Source File: MapViewHandler.java    From PowerSwitch_Android with GNU General Public License v3.0 5 votes vote down vote up
public void updateMarker(String id, MarkerOptions markerOptions) {
    Marker marker = markers.get(id);
    marker.setPosition(markerOptions.getPosition());
    marker.setAlpha(markerOptions.getAlpha());
    marker.setDraggable(markerOptions.isDraggable());
    marker.setFlat(markerOptions.isFlat());
    marker.setIcon(markerOptions.getIcon());
    marker.setVisible(markerOptions.isVisible());
    marker.setTitle(markerOptions.getTitle());
    marker.setSnippet(markerOptions.getSnippet());
    marker.setRotation(markerOptions.getRotation());
    marker.setAnchor(markerOptions.getAnchorU(), markerOptions.getAnchorV());
    marker.setInfoWindowAnchor(markerOptions.getInfoWindowAnchorU(), markerOptions.getInfoWindowAnchorV());
}
 
Example 9
Source File: LocationMarkerCollection.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 : userIdToMarker.values()) {
		m.setVisible(visible);
	}
	if (clickedAccuracyCircle != null) {
		clickedAccuracyCircle.setVisible(visible);
	}
}
 
Example 10
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 11
Source File: Renderer.java    From android-maps-utils with Apache License 2.0 4 votes vote down vote up
/**
 * Adds a single geometry object to the map with its specified style (used for KML)
 *
 * @param geometry defines the type of object to add to the map
 * @param style    defines styling properties to add to the object when added to the map
 * @return the object that was added to the map, this is a Marker, Polyline, Polygon or an array
 * of either objects
 */
protected Object addKmlPlacemarkToMap(KmlPlacemark placemark, Geometry geometry, KmlStyle style,
                                      KmlStyle inlineStyle, boolean isVisible) {
    String geometryType = geometry.getGeometryType();
    boolean hasDrawOrder = placemark.hasProperty("drawOrder");
    float drawOrder = 0;

    if (hasDrawOrder) {
        try {
            drawOrder = Float.parseFloat(placemark.getProperty("drawOrder"));
        } catch (NumberFormatException e) {
            hasDrawOrder = false;
        }
    }
    switch (geometryType) {
        case "Point":
            MarkerOptions markerOptions = style.getMarkerOptions();
            if (inlineStyle != null) {
                setInlinePointStyle(markerOptions, inlineStyle, style);
            } else if (style.getIconUrl() != null) {
                // Use shared style
                addMarkerIcons(style.getIconUrl(), style.getIconScale(), markerOptions);
            }
            Marker marker = addPointToMap(markerOptions, (KmlPoint) geometry);
            marker.setVisible(isVisible);
            setMarkerInfoWindow(style, marker, placemark);
            if (hasDrawOrder) {
                marker.setZIndex(drawOrder);
            }
            return marker;
        case "LineString":
            PolylineOptions polylineOptions = style.getPolylineOptions();
            if (inlineStyle != null) {
                setInlineLineStringStyle(polylineOptions, inlineStyle);
            } else if (style.isLineRandomColorMode()) {
                polylineOptions.color(KmlStyle.computeRandomColor(polylineOptions.getColor()));
            }
            Polyline polyline = addLineStringToMap(polylineOptions, (LineString) geometry);
            polyline.setVisible(isVisible);
            if (hasDrawOrder) {
                polyline.setZIndex(drawOrder);
            }
            return polyline;
        case "Polygon":
            PolygonOptions polygonOptions = style.getPolygonOptions();
            if (inlineStyle != null) {
                setInlinePolygonStyle(polygonOptions, inlineStyle);
            } else if (style.isPolyRandomColorMode()) {
                polygonOptions.fillColor(KmlStyle.computeRandomColor(polygonOptions.getFillColor()));
            }
            Polygon polygon = addPolygonToMap(polygonOptions, (DataPolygon) geometry);
            polygon.setVisible(isVisible);
            if (hasDrawOrder) {
                polygon.setZIndex(drawOrder);
            }
            return polygon;
        case "MultiGeometry":
            return addMultiGeometryToMap(placemark, (KmlMultiGeometry) geometry, style, inlineStyle,
                    isVisible);
    }
    return null;
}
 
Example 12
Source File: MarkerManager.java    From android-maps-utils with Apache License 2.0 4 votes vote down vote up
public void showAll() {
    for (Marker marker : getMarkers()) {
        marker.setVisible(true);
    }
}
 
Example 13
Source File: MarkerManager.java    From android-maps-utils with Apache License 2.0 4 votes vote down vote up
public void hideAll() {
    for (Marker marker : getMarkers()) {
        marker.setVisible(false);
    }
}