Search in sources :

Example 21 with MarkerOptions

use of com.google.android.gms.maps.model.MarkerOptions in project android-maps-utils by googlemaps.

the class Renderer method addKmlPlacemarkToMap.

/**
     * 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.getIconUrl());
            } else if (style.getIconUrl() != null) {
                // Use shared style
                addMarkerIcons(style.getIconUrl(), 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;
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) PolygonOptions(com.google.android.gms.maps.model.PolygonOptions) Polyline(com.google.android.gms.maps.model.Polyline) GeoJsonLineString(com.google.maps.android.data.geojson.GeoJsonLineString) GeoJsonMultiLineString(com.google.maps.android.data.geojson.GeoJsonMultiLineString) Marker(com.google.android.gms.maps.model.Marker) Polygon(com.google.android.gms.maps.model.Polygon) GeoJsonPolygon(com.google.maps.android.data.geojson.GeoJsonPolygon) GeoJsonMultiPolygon(com.google.maps.android.data.geojson.GeoJsonMultiPolygon) PolylineOptions(com.google.android.gms.maps.model.PolylineOptions)

Example 22 with MarkerOptions

use of com.google.android.gms.maps.model.MarkerOptions in project android-maps-utils by googlemaps.

the class KmlStyle method createMarkerOptions.

/**
     * Creates a new marker option from given properties of an existing marker option
     *
     * @param originalMarkerOption An existing MarkerOption instance
     * @param iconRandomColorMode  True if marker color mode is random, false otherwise
     * @param markerColor          Color of the marker
     * @return A new MarkerOption
     */
private static MarkerOptions createMarkerOptions(MarkerOptions originalMarkerOption, boolean iconRandomColorMode, float markerColor) {
    MarkerOptions newMarkerOption = new MarkerOptions();
    newMarkerOption.rotation(originalMarkerOption.getRotation());
    newMarkerOption.anchor(originalMarkerOption.getAnchorU(), originalMarkerOption.getAnchorV());
    if (iconRandomColorMode) {
        float hue = getHueValue(computeRandomColor((int) markerColor));
        originalMarkerOption.icon(BitmapDescriptorFactory.defaultMarker(hue));
    }
    newMarkerOption.icon(originalMarkerOption.getIcon());
    return newMarkerOption;
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions)

Example 23 with MarkerOptions

use of com.google.android.gms.maps.model.MarkerOptions in project actor-platform by actorapp.

the class MapFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    longitude = getArguments().getDouble("longitude");
    latitude = getArguments().getDouble("latitude");
    final MapView map = new MapView(getActivity());
    map.onCreate(null);
    map.getMapAsync(new OnMapReadyCallback() {

        @Override
        public void onMapReady(GoogleMap googleMap) {
            mapController = googleMap;
            googleMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).title(""));
            googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), 16));
            map.onResume();
        }
    });
    return map;
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) GoogleMap(com.google.android.gms.maps.GoogleMap) MapView(com.google.android.gms.maps.MapView) OnMapReadyCallback(com.google.android.gms.maps.OnMapReadyCallback) LatLng(com.google.android.gms.maps.model.LatLng)

Example 24 with MarkerOptions

use of com.google.android.gms.maps.model.MarkerOptions in project Signal-Android by WhisperSystems.

the class SignalMapView method display.

public ListenableFuture<Bitmap> display(final SignalPlace place) {
    final SettableFuture<Bitmap> future = new SettableFuture<>();
    this.mapView.onCreate(null);
    this.mapView.onResume();
    this.mapView.setVisibility(View.VISIBLE);
    this.imageView.setVisibility(View.GONE);
    this.mapView.getMapAsync(new OnMapReadyCallback() {

        @Override
        public void onMapReady(final GoogleMap googleMap) {
            googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(place.getLatLong(), 13));
            googleMap.addMarker(new MarkerOptions().position(place.getLatLong()));
            googleMap.setBuildingsEnabled(true);
            googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
            googleMap.getUiSettings().setAllGesturesEnabled(false);
            googleMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {

                @Override
                public void onMapLoaded() {
                    googleMap.snapshot(new GoogleMap.SnapshotReadyCallback() {

                        @Override
                        public void onSnapshotReady(Bitmap bitmap) {
                            future.set(bitmap);
                            imageView.setImageBitmap(bitmap);
                            imageView.setVisibility(View.VISIBLE);
                            mapView.setVisibility(View.GONE);
                            mapView.onPause();
                            mapView.onDestroy();
                        }
                    });
                }
            });
        }
    });
    this.textView.setText(place.getDescription());
    return future;
}
Also used : SettableFuture(org.thoughtcrime.securesms.util.concurrent.SettableFuture) Bitmap(android.graphics.Bitmap) MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) GoogleMap(com.google.android.gms.maps.GoogleMap) OnMapReadyCallback(com.google.android.gms.maps.OnMapReadyCallback)

Example 25 with MarkerOptions

use of com.google.android.gms.maps.model.MarkerOptions in project Android-GoogleDirectionAndPlaceLibrary by akexorcist.

the class DirectionActivity1 method onCreate.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_direction_1);
    mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(start, 15));
    gd = new GoogleDirection(this);
    gd.setOnDirectionResponseListener(new OnDirectionResponseListener() {

        public void onResponse(String status, Document doc, GoogleDirection gd) {
            mDoc = doc;
            mMap.addPolyline(gd.getPolyline(doc, 3, Color.RED));
            mMap.addMarker(new MarkerOptions().position(start).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
            mMap.addMarker(new MarkerOptions().position(end).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
            buttonAnimate.setVisibility(View.VISIBLE);
        }
    });
    gd.setOnAnimateListener(new OnAnimateListener() {

        public void onStart() {
            textProgress.setVisibility(View.VISIBLE);
        }

        public void onProgress(int progress, int total) {
            textProgress.setText(progress + " / " + total);
        }

        public void onFinish() {
            buttonAnimate.setVisibility(View.VISIBLE);
            textProgress.setVisibility(View.GONE);
        }
    });
    textProgress = (TextView) findViewById(R.id.textProgress);
    textProgress.setVisibility(View.GONE);
    buttonRequest = (Button) findViewById(R.id.buttonRequest);
    buttonRequest.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            v.setVisibility(View.GONE);
            gd.setLogging(true);
            gd.request(start, end, GoogleDirection.MODE_DRIVING);
        }
    });
    buttonAnimate = (Button) findViewById(R.id.buttonAnimate);
    buttonAnimate.setVisibility(View.GONE);
    buttonAnimate.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            v.setVisibility(View.GONE);
            gd.animateDirection(mMap, gd.getDirection(mDoc), GoogleDirection.SPEED_FAST, true, false, true, false, null, false, true, null);
        }
    });
}
Also used : GoogleDirection(app.akexorcist.gdaplibrary.GoogleDirection) MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) OnAnimateListener(app.akexorcist.gdaplibrary.GoogleDirection.OnAnimateListener) OnDirectionResponseListener(app.akexorcist.gdaplibrary.GoogleDirection.OnDirectionResponseListener) OnClickListener(android.view.View.OnClickListener) Document(org.w3c.dom.Document) TextView(android.widget.TextView) View(android.view.View)

Aggregations

MarkerOptions (com.google.android.gms.maps.model.MarkerOptions)39 LatLng (com.google.android.gms.maps.model.LatLng)24 BitmapDescriptor (com.google.android.gms.maps.model.BitmapDescriptor)7 Marker (com.google.android.gms.maps.model.Marker)6 GoogleMap (com.google.android.gms.maps.GoogleMap)5 Bitmap (android.graphics.Bitmap)4 View (android.view.View)4 Document (org.w3c.dom.Document)4 OnClickListener (android.view.View.OnClickListener)3 GoogleDirection (app.akexorcist.gdaplibrary.GoogleDirection)3 OnDirectionResponseListener (app.akexorcist.gdaplibrary.GoogleDirection.OnDirectionResponseListener)3 OnMapReadyCallback (com.google.android.gms.maps.OnMapReadyCallback)3 PolylineOptions (com.google.android.gms.maps.model.PolylineOptions)3 RemoteImageLoader (com.omkarmoghe.pokemap.helpers.RemoteImageLoader)3 TextView (android.widget.TextView)2 OnAnimateListener (app.akexorcist.gdaplibrary.GoogleDirection.OnAnimateListener)2 CameraPosition (com.google.android.gms.maps.model.CameraPosition)2 CircleOptions (com.google.android.gms.maps.model.CircleOptions)2 PokemonIdOuterClass (POGOProtos.Enums.PokemonIdOuterClass)1 FortDataOuterClass (POGOProtos.Map.Fort.FortDataOuterClass)1