Search in sources :

Example 1 with MapStyleOptions

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

the class CapacitorGoogleMaps method setMapStyle.

@PluginMethod()
public void setMapStyle(PluginCall call) {
    /*
            https://mapstyle.withgoogle.com/
        */
    final String mapStyle = call.getString("jsonString", "");
    getBridge().executeOnMainThread(new Runnable() {

        @Override
        public void run() {
            MapStyleOptions mapStyleOptions = new MapStyleOptions(mapStyle);
            googleMap.setMapStyle(mapStyleOptions);
        }
    });
}
Also used : MapStyleOptions(com.google.android.libraries.maps.model.MapStyleOptions) PluginMethod(com.getcapacitor.PluginMethod)

Example 2 with MapStyleOptions

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

the class StyledMapDemoActivity method setSelectedStyle.

/**
 * Creates a {@link MapStyleOptions} object via loadRawResourceStyle() (or via the
 * constructor with a JSON String), then sets it on the {@link GoogleMap} instance,
 * via the setMapStyle() method.
 */
private void setSelectedStyle() {
    MapStyleOptions style;
    switch(mSelectedStyleId) {
        case R.string.style_label_retro:
            // Sets the retro style via raw resource JSON.
            style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_retro);
            break;
        case R.string.style_label_night:
            // Sets the night style via raw resource JSON.
            style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_night);
            break;
        case R.string.style_label_grayscale:
            // Sets the grayscale style via raw resource JSON.
            style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_grayscale);
            break;
        case R.string.style_label_no_pois_no_transit:
            // Sets the no POIs or transit style via JSON string.
            style = new MapStyleOptions("[" + "  {" + "    \"featureType\":\"poi.business\"," + "    \"elementType\":\"all\"," + "    \"stylers\":[" + "      {" + "        \"visibility\":\"off\"" + "      }" + "    ]" + "  }," + "  {" + "    \"featureType\":\"transit\"," + "    \"elementType\":\"all\"," + "    \"stylers\":[" + "      {" + "        \"visibility\":\"off\"" + "      }" + "    ]" + "  }" + "]");
            break;
        case R.string.style_label_default:
            // Removes previously set style, by setting it to null.
            style = null;
            break;
        default:
            return;
    }
    mMap.setMapStyle(style);
}
Also used : MapStyleOptions(com.google.android.libraries.maps.model.MapStyleOptions)

Aggregations

MapStyleOptions (com.google.android.libraries.maps.model.MapStyleOptions)2 PluginMethod (com.getcapacitor.PluginMethod)1