Search in sources :

Example 16 with LatLng

use of com.google.android.libraries.maps.model.LatLng in project android-samples by googlemaps.

the class PolygonDemoActivity method onMapReady.

@Override
public void onMapReady(GoogleMap map) {
    // Override the default content description on the view, for accessibility mode.
    map.setContentDescription(getString(R.string.polygon_demo_description));
    int fillColorArgb = Color.HSVToColor(fillAlphaBar.getProgress(), new float[] { fillHueBar.getProgress(), 1, 1 });
    int strokeColorArgb = Color.HSVToColor(strokeAlphaBar.getProgress(), new float[] { strokeHueBar.getProgress(), 1, 1 });
    // Create a rectangle with two rectangular holes.
    mutablePolygon = map.addPolygon(new PolygonOptions().addAll(createRectangle(CENTER, 5, 5)).addHole(createRectangle(new LatLng(-22, 128), 1, 1)).addHole(createRectangle(new LatLng(-18, 133), 0.5, 1.5)).fillColor(fillColorArgb).strokeColor(strokeColorArgb).strokeWidth(strokeWidthBar.getProgress()).clickable(clickabilityCheckbox.isChecked()));
    fillHueBar.setOnSeekBarChangeListener(this);
    fillAlphaBar.setOnSeekBarChangeListener(this);
    strokeWidthBar.setOnSeekBarChangeListener(this);
    strokeHueBar.setOnSeekBarChangeListener(this);
    strokeAlphaBar.setOnSeekBarChangeListener(this);
    strokeJointTypeSpinner.setOnItemSelectedListener(this);
    strokePatternSpinner.setOnItemSelectedListener(this);
    mutablePolygon.setStrokeJointType(getSelectedJointType(strokeJointTypeSpinner.getSelectedItemPosition()));
    mutablePolygon.setStrokePattern(getSelectedPattern(strokePatternSpinner.getSelectedItemPosition()));
    // Move the map so that it is centered on the mutable polygon.
    map.moveCamera(CameraUpdateFactory.newLatLngZoom(CENTER, 4));
    // Add a listener for polygon clicks that changes the clicked polygon's stroke color.
    map.setOnPolygonClickListener(new GoogleMap.OnPolygonClickListener() {

        @Override
        public void onPolygonClick(Polygon polygon) {
            // Flip the red, green and blue components of the polygon's stroke color.
            polygon.setStrokeColor(polygon.getStrokeColor() ^ 0x00ffffff);
        }
    });
}
Also used : PolygonOptions(com.google.android.libraries.maps.model.PolygonOptions) GoogleMap(com.google.android.libraries.maps.GoogleMap) LatLng(com.google.android.libraries.maps.model.LatLng) Polygon(com.google.android.libraries.maps.model.Polygon)

Example 17 with LatLng

use of com.google.android.libraries.maps.model.LatLng in project android-samples by googlemaps.

the class SplitStreetViewPanoramaAndMapDemoActivity method onCreate.

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.split_street_view_panorama_and_map_demo);
    final LatLng markerPosition;
    if (savedInstanceState == null) {
        markerPosition = SYDNEY;
    } else {
        markerPosition = savedInstanceState.getParcelable(MARKER_POSITION_KEY);
    }
    SupportStreetViewPanoramaFragment streetViewPanoramaFragment = (SupportStreetViewPanoramaFragment) getSupportFragmentManager().findFragmentById(R.id.streetviewpanorama);
    streetViewPanoramaFragment.getStreetViewPanoramaAsync(new OnStreetViewPanoramaReadyCallback() {

        @Override
        public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
            streetViewPanorama = panorama;
            streetViewPanorama.setOnStreetViewPanoramaChangeListener(SplitStreetViewPanoramaAndMapDemoActivity.this);
            // its state.
            if (savedInstanceState == null) {
                streetViewPanorama.setPosition(SYDNEY);
            }
        }
    });
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(new OnMapReadyCallback() {

        @Override
        public void onMapReady(GoogleMap map) {
            map.setOnMarkerDragListener(SplitStreetViewPanoramaAndMapDemoActivity.this);
            // Creates a draggable marker. Long press to drag.
            marker = map.addMarker(new MarkerOptions().position(markerPosition).icon(BitmapDescriptorFactory.fromResource(R.drawable.pegman)).draggable(true));
        }
    });
}
Also used : SupportMapFragment(com.google.android.libraries.maps.SupportMapFragment) StreetViewPanorama(com.google.android.libraries.maps.StreetViewPanorama) MarkerOptions(com.google.android.libraries.maps.model.MarkerOptions) OnStreetViewPanoramaReadyCallback(com.google.android.libraries.maps.OnStreetViewPanoramaReadyCallback) GoogleMap(com.google.android.libraries.maps.GoogleMap) OnMapReadyCallback(com.google.android.libraries.maps.OnMapReadyCallback) LatLng(com.google.android.libraries.maps.model.LatLng) SupportStreetViewPanoramaFragment(com.google.android.libraries.maps.SupportStreetViewPanoramaFragment)

Example 18 with LatLng

use of com.google.android.libraries.maps.model.LatLng in project android-samples by googlemaps.

the class TagsDemoActivity method addObjectsToMap.

private void addObjectsToMap() {
    // A circle centered on Adelaide.
    mAdelaideCircle = mMap.addCircle(new CircleOptions().center(ADELAIDE).radius(500000).fillColor(Color.argb(150, 66, 173, 244)).strokeColor(Color.rgb(66, 173, 244)).clickable(true));
    mAdelaideCircle.setTag(new CustomTag("Adelaide circle"));
    // A ground overlay at Sydney.
    mSydneyGroundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions().image(BitmapDescriptorFactory.fromResource(R.drawable.harbour_bridge)).position(SYDNEY, 700000).clickable(true));
    mSydneyGroundOverlay.setTag(new CustomTag("Sydney ground overlay"));
    // A marker at Hobart.
    mHobartMarker = mMap.addMarker(new MarkerOptions().position(HOBART));
    mHobartMarker.setTag(new CustomTag("Hobart marker"));
    // A polygon centered at Darwin.
    mDarwinPolygon = mMap.addPolygon(new PolygonOptions().add(new LatLng(DARWIN.latitude + 3, DARWIN.longitude - 3), new LatLng(DARWIN.latitude + 3, DARWIN.longitude + 3), new LatLng(DARWIN.latitude - 3, DARWIN.longitude + 3), new LatLng(DARWIN.latitude - 3, DARWIN.longitude - 3)).fillColor(Color.argb(150, 34, 173, 24)).strokeColor(Color.rgb(34, 173, 24)).clickable(true));
    mDarwinPolygon.setTag(new CustomTag("Darwin polygon"));
    // A polyline from Perth to Brisbane.
    mPolyline = mMap.addPolyline(new PolylineOptions().add(PERTH, BRISBANE).color(Color.rgb(103, 24, 173)).width(30).clickable(true));
    mPolyline.setTag(new CustomTag("Perth to Brisbane polyline"));
}
Also used : MarkerOptions(com.google.android.libraries.maps.model.MarkerOptions) CircleOptions(com.google.android.libraries.maps.model.CircleOptions) GroundOverlayOptions(com.google.android.libraries.maps.model.GroundOverlayOptions) PolygonOptions(com.google.android.libraries.maps.model.PolygonOptions) LatLng(com.google.android.libraries.maps.model.LatLng) PolylineOptions(com.google.android.libraries.maps.model.PolylineOptions)

Example 19 with LatLng

use of com.google.android.libraries.maps.model.LatLng in project android-maps-utils by googlemaps.

the class BigClusteringDemoActivity method readItems.

private void readItems() throws JSONException {
    InputStream inputStream = getResources().openRawResource(R.raw.radar_search);
    List<MyItem> items = new MyItemReader().read(inputStream);
    for (int i = 0; i < 10; i++) {
        double offset = i / 60d;
        for (MyItem item : items) {
            LatLng position = item.getPosition();
            double lat = position.latitude + offset;
            double lng = position.longitude + offset;
            MyItem offsetItem = new MyItem(lat, lng);
            mClusterManager.addItem(offsetItem);
        }
    }
}
Also used : InputStream(java.io.InputStream) LatLng(com.google.android.libraries.maps.model.LatLng) MyItem(com.google.maps.android.utils.demo.model.MyItem)

Example 20 with LatLng

use of com.google.android.libraries.maps.model.LatLng in project android-maps-utils by googlemaps.

the class ClusteringViewModel method readItems.

void readItems(Resources resources) throws JSONException {
    InputStream inputStream = resources.openRawResource(R.raw.radar_search);
    List<MyItem> items = new MyItemReader().read(inputStream);
    mAlgorithm.lock();
    try {
        for (int i = 0; i < 100; i++) {
            double offset = i / 60d;
            for (MyItem item : items) {
                LatLng position = item.getPosition();
                double lat = position.latitude + offset;
                double lng = position.longitude + offset;
                MyItem offsetItem = new MyItem(lat, lng);
                mAlgorithm.addItem(offsetItem);
            }
        }
    } finally {
        mAlgorithm.unlock();
    }
}
Also used : InputStream(java.io.InputStream) LatLng(com.google.android.libraries.maps.model.LatLng) MyItem(com.google.maps.android.utils.demo.model.MyItem)

Aggregations

LatLng (com.google.android.libraries.maps.model.LatLng)31 JSONException (org.json.JSONException)8 MarkerOptions (com.google.android.libraries.maps.model.MarkerOptions)7 PluginMethod (com.getcapacitor.PluginMethod)5 PolylineOptions (com.google.android.libraries.maps.model.PolylineOptions)5 MyItem (com.google.maps.android.utils.demo.model.MyItem)5 InputStream (java.io.InputStream)5 JSONObject (org.json.JSONObject)5 PolygonOptions (com.google.android.libraries.maps.model.PolygonOptions)4 Nullable (androidx.annotation.Nullable)3 GoogleMap (com.google.android.libraries.maps.GoogleMap)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 JSONArray (org.json.JSONArray)3 DisplayMetrics (android.util.DisplayMetrics)2 Log (android.util.Log)2 View (android.view.View)2 CircleOptions (com.google.android.libraries.maps.model.CircleOptions)2 LatLngBounds (com.google.android.libraries.maps.model.LatLngBounds)2 Marker (com.google.android.libraries.maps.model.Marker)2