Search in sources :

Example 16 with MarkerOptions

use of com.google.android.gms.maps.model.MarkerOptions in project NPSmiles by bmcglynn1.

the class ItemOneFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.activity_contact_page, container, false);
    SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);
    OnMapReadyCallback obj = new OnMapReadyCallback() {

        @Override
        public void onMapReady(GoogleMap googleMap) {
            mMap = googleMap;
            LatLng smiles = new LatLng(39.104729, -77.191294);
            mMap.addMarker(new MarkerOptions().position(smiles).title("North Potomac Smiles, LLC."));
            mMap.moveCamera(CameraUpdateFactory.newLatLng(smiles));
            mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(smiles, 16));
        }
    };
    mapFragment.getMapAsync(obj);
    return view;
}
Also used : SupportMapFragment(com.google.android.gms.maps.SupportMapFragment) MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) GoogleMap(com.google.android.gms.maps.GoogleMap) OnMapReadyCallback(com.google.android.gms.maps.OnMapReadyCallback) LatLng(com.google.android.gms.maps.model.LatLng) View(android.view.View)

Example 17 with MarkerOptions

use of com.google.android.gms.maps.model.MarkerOptions in project iosched by google.

the class MarkerLoadingTask method loadInBackground.

@Override
public List<MarkerEntry> loadInBackground() {
    List<MarkerEntry> list = null;
    // Create a URI to get a cursor of all map markers
    final Uri uri = ScheduleContract.MapMarkers.buildMarkerUri();
    Cursor cursor = getContext().getContentResolver().query(uri, MarkerQuery.PROJECTION, null, null, null);
    // Create a MarkerModel for each entry
    final int count = cursor.getCount();
    if (cursor != null) {
        list = new ArrayList<>(count);
        final IconGenerator labelIconGenerator = MapUtils.getLabelIconGenerator(getContext());
        cursor.moveToFirst();
        while (!cursor.isAfterLast()) {
            // get data
            final String id = cursor.getString(MarkerQuery.MARKER_ID);
            final int floor = cursor.getInt(MarkerQuery.MARKER_FLOOR);
            final float lat = cursor.getFloat(MarkerQuery.MARKER_LATITUDE);
            final float lon = cursor.getFloat(MarkerQuery.MARKER_LONGITUDE);
            final String typeString = cursor.getString(MarkerQuery.MARKER_TYPE);
            final int type = MapUtils.detectMarkerType(typeString);
            final String label = cursor.getString(MarkerQuery.MARKER_LABEL);
            final LatLng position = new LatLng(lat, lon);
            MarkerOptions marker = null;
            if (type == MarkerModel.TYPE_LABEL) {
                // Label markers contain the label as its icon
                marker = MapUtils.createLabelMarker(labelIconGenerator, id, position, label);
            } else if (type == MarkerModel.TYPE_ICON) {
                // An icon marker is mapped to a drawable based on its full type name
                marker = MapUtils.createIconMarker(typeString, id, position, getContext());
            } else if (type != MarkerModel.TYPE_INACTIVE) {
                // All other markers (that are not inactive) contain a pin icon
                marker = MapUtils.createPinMarker(id, position);
            }
            MarkerModel model = new MarkerModel(id, floor, type, label, null);
            MarkerEntry entry = new MarkerEntry(model, marker);
            list.add(entry);
            cursor.moveToNext();
        }
        cursor.close();
    }
    return list;
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) LatLng(com.google.android.gms.maps.model.LatLng) Cursor(android.database.Cursor) Uri(android.net.Uri) IconGenerator(com.google.maps.android.ui.IconGenerator)

Example 18 with MarkerOptions

use of com.google.android.gms.maps.model.MarkerOptions in project iosched by google.

the class MapUtils method createVenueMarker.

/**
     * Creates a marker for the venue.
     */
public static MarkerOptions createVenueMarker(LatLng position) {
    final String title = "VENUE";
    final BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.map_marker_venue);
    return new MarkerOptions().position(position).title(title).icon(icon).visible(false);
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) BitmapDescriptor(com.google.android.gms.maps.model.BitmapDescriptor)

Example 19 with MarkerOptions

use of com.google.android.gms.maps.model.MarkerOptions in project iosched by google.

the class MapUtils method createIconMarker.

/**
     * Creates a marker for an icon. The icon is selected in {@link #getDrawableForIconType(Context,
     * String)} and anchored at the bottom center for the location.
     */
public static MarkerOptions createIconMarker(final String iconType, final String id, LatLng position, Context context) {
    final int iconResource = getDrawableForIconType(context, iconType);
    if (iconResource < 1) {
        // Not a valid icon type.
        return null;
    }
    final BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(iconResource);
    return new MarkerOptions().position(position).title(id).icon(icon).anchor(0.5f, 1f).visible(false);
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) BitmapDescriptor(com.google.android.gms.maps.model.BitmapDescriptor)

Example 20 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)

Aggregations

MarkerOptions (com.google.android.gms.maps.model.MarkerOptions)38 LatLng (com.google.android.gms.maps.model.LatLng)23 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