Search in sources :

Example 26 with LatLng

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

the class TileProviderAndProjectionDemo method startDemo.

@Override
protected void startDemo(boolean isRestore) {
    PointTileOverlay pto = new PointTileOverlay();
    pto.addPoint(new LatLng(0, 0));
    pto.addPoint(new LatLng(21, -10));
    getMap().addTileOverlay(new TileOverlayOptions().tileProvider(pto));
}
Also used : TileOverlayOptions(com.google.android.libraries.maps.model.TileOverlayOptions) LatLng(com.google.android.libraries.maps.model.LatLng)

Example 27 with LatLng

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

the class VisibleClusteringDemoActivity 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 < 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);
            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 28 with LatLng

use of com.google.android.libraries.maps.model.LatLng in project google-maps by capacitor-community.

the class CapacitorGoogleMaps method addCircle.

@PluginMethod()
public void addCircle(final PluginCall call) {
    final int radius = call.getInt("radius", 0);
    final JSONObject center = call.getObject("center", new JSObject());
    getBridge().executeOnMainThread(new Runnable() {

        @Override
        public void run() {
            CircleOptions circleOptions = new CircleOptions();
            circleOptions.radius(radius);
            try {
                circleOptions.center(new LatLng(center.getDouble("latitude"), center.getDouble("longitude")));
            } catch (JSONException e) {
                e.printStackTrace();
            }
            googleMap.addCircle(circleOptions);
            call.resolve();
        }
    });
}
Also used : JSONObject(org.json.JSONObject) CircleOptions(com.google.android.libraries.maps.model.CircleOptions) JSObject(com.getcapacitor.JSObject) JSONException(org.json.JSONException) LatLng(com.google.android.libraries.maps.model.LatLng) SuppressLint(android.annotation.SuppressLint) PluginMethod(com.getcapacitor.PluginMethod)

Example 29 with LatLng

use of com.google.android.libraries.maps.model.LatLng in project google-maps by capacitor-community.

the class CapacitorGoogleMaps method addPolygon.

@PluginMethod()
public void addPolygon(final PluginCall call) {
    final JSArray points = call.getArray("points", new JSArray());
    getBridge().executeOnMainThread(new Runnable() {

        @Override
        public void run() {
            PolygonOptions polygonOptions = new PolygonOptions();
            for (int i = 0; i < points.length(); i++) {
                try {
                    JSONObject point = points.getJSONObject(i);
                    LatLng latLng = new LatLng(point.getDouble("latitude"), point.getDouble("longitude"));
                    polygonOptions.add(latLng);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
            googleMap.addPolygon(polygonOptions);
            call.resolve();
        }
    });
}
Also used : JSONObject(org.json.JSONObject) PolygonOptions(com.google.android.libraries.maps.model.PolygonOptions) JSArray(com.getcapacitor.JSArray) JSONException(org.json.JSONException) LatLng(com.google.android.libraries.maps.model.LatLng) PluginMethod(com.getcapacitor.PluginMethod)

Example 30 with LatLng

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

the class ProgrammaticAutocompleteToolbarActivity method getPlacePredictions.

/**
 * This method demonstrates the programmatic approach to getting place predictions. The
 * parameters in this request are currently biased to Kolkata, India.
 *
 * @param query the plus code query string (e.g. "GCG2+3M K")
 */
private void getPlacePredictions(String query) {
    // The value of 'bias' biases prediction results to the rectangular region provided
    // (currently Kolkata). Modify these values to get results for another area. Make sure to
    // pass in the appropriate value/s for .setCountries() in the
    // FindAutocompletePredictionsRequest.Builder object as well.
    final LocationBias bias = RectangularBounds.newInstance(// SW lat, lng
    new LatLng(22.458744, 88.208162), // NE lat, lng
    new LatLng(22.730671, 88.524896));
    // Create a new programmatic Place Autocomplete request in Places SDK for Android
    final FindAutocompletePredictionsRequest newRequest = FindAutocompletePredictionsRequest.builder().setSessionToken(sessionToken).setLocationBias(bias).setTypeFilter(TypeFilter.ESTABLISHMENT).setQuery(query).setCountries("IN").build();
    // Perform autocomplete predictions request
    placesClient.findAutocompletePredictions(newRequest).addOnSuccessListener((response) -> {
        List<AutocompletePrediction> predictions = response.getAutocompletePredictions();
        adapter.setPredictions(predictions);
        progressBar.setIndeterminate(false);
        viewAnimator.setDisplayedChild(predictions.isEmpty() ? 0 : 1);
    }).addOnFailureListener((exception) -> {
        progressBar.setIndeterminate(false);
        if (exception instanceof ApiException) {
            ApiException apiException = (ApiException) exception;
            Log.e(TAG, "Place not found: " + apiException.getStatusCode());
        }
    });
}
Also used : DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) TypeFilter(com.google.android.libraries.places.api.model.TypeFilter) AutocompleteSessionToken(com.google.android.libraries.places.api.model.AutocompleteSessionToken) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) ProgressBar(android.widget.ProgressBar) NonNull(androidx.annotation.NonNull) Volley(com.android.volley.toolbox.Volley) PlacesClient(com.google.android.libraries.places.api.net.PlacesClient) GeocodingResult(com.example.placesdemo.model.GeocodingResult) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) GsonBuilder(com.google.gson.GsonBuilder) MenuItem(android.view.MenuItem) JSONException(org.json.JSONException) R(com.example.placesdemo.R) Gson(com.google.gson.Gson) Handler(android.os.Handler) Menu(android.view.Menu) RecyclerView(androidx.recyclerview.widget.RecyclerView) Log(android.util.Log) LocationBias(com.google.android.libraries.places.api.model.LocationBias) JsonObjectRequest(com.android.volley.toolbox.JsonObjectRequest) Method(com.android.volley.Request.Method) SearchView(android.widget.SearchView) RequestQueue(com.android.volley.RequestQueue) FindAutocompletePredictionsRequest(com.google.android.libraries.places.api.net.FindAutocompletePredictionsRequest) MainActivity(com.example.placesdemo.MainActivity) LatLng(com.google.android.libraries.maps.model.LatLng) Places(com.google.android.libraries.places.api.Places) RectangularBounds(com.google.android.libraries.places.api.model.RectangularBounds) List(java.util.List) Nullable(androidx.annotation.Nullable) BuildConfig(com.example.placesdemo.BuildConfig) ViewAnimator(android.widget.ViewAnimator) AutocompletePrediction(com.google.android.libraries.places.api.model.AutocompletePrediction) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) OnQueryTextListener(android.widget.SearchView.OnQueryTextListener) ApiException(com.google.android.gms.common.api.ApiException) JSONArray(org.json.JSONArray) LocationBias(com.google.android.libraries.places.api.model.LocationBias) FindAutocompletePredictionsRequest(com.google.android.libraries.places.api.net.FindAutocompletePredictionsRequest) List(java.util.List) LatLng(com.google.android.libraries.maps.model.LatLng) ApiException(com.google.android.gms.common.api.ApiException)

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