|
13 | 13 | import android.widget.TextView; |
14 | 14 | import android.widget.Toast; |
15 | 15 |
|
| 16 | +import com.airbnb.android.airmapview.AirGoogleMapOptions; |
16 | 17 | import com.airbnb.android.airmapview.AirMapGeoJsonLayer; |
17 | 18 | import com.airbnb.android.airmapview.AirMapInterface; |
18 | 19 | import com.airbnb.android.airmapview.AirMapMarker; |
|
30 | 31 | import com.airbnb.android.airmapview.listeners.OnLatLngScreenLocationCallback; |
31 | 32 | import com.airbnb.android.airmapview.listeners.OnMapClickListener; |
32 | 33 | import com.airbnb.android.airmapview.listeners.OnMapInitializedListener; |
| 34 | +import com.airbnb.android.airmapview.listeners.OnMapLoadedListener; |
33 | 35 | import com.airbnb.android.airmapview.listeners.OnMapMarkerClickListener; |
| 36 | +import com.google.android.gms.maps.GoogleMapOptions; |
34 | 37 | import com.google.android.gms.maps.model.LatLng; |
35 | 38 | import com.google.android.gms.maps.model.Marker; |
36 | 39 |
|
@@ -122,6 +125,24 @@ public class MainActivity extends AppCompatActivity |
122 | 125 | case R.id.action_clear_logs: |
123 | 126 | textLogs.setText(""); |
124 | 127 | break; |
| 128 | + case R.id.action_web_map_no_touch: |
| 129 | + try { |
| 130 | + airMapInterface = createMapWithTouchDisabled(AirMapViewTypes.WEB); |
| 131 | + } catch (UnsupportedOperationException e) { |
| 132 | + Toast.makeText(this, "Sorry, native Google Maps are not supported by this device. " + |
| 133 | + "Please make sure you have Google Play Services installed.", |
| 134 | + Toast.LENGTH_SHORT).show(); |
| 135 | + } |
| 136 | + break; |
| 137 | + case R.id.action_native_map_no_touch: |
| 138 | + try { |
| 139 | + airMapInterface = createMapWithTouchDisabled(AirMapViewTypes.NATIVE); |
| 140 | + } catch (UnsupportedOperationException e) { |
| 141 | + Toast.makeText(this, "Sorry, native Google Maps are not supported by this device. " + |
| 142 | + "Please make sure you have Google Play Services installed.", |
| 143 | + Toast.LENGTH_SHORT).show(); |
| 144 | + } |
| 145 | + break; |
125 | 146 | case R.id.add_geojson_layer: |
126 | 147 | // Draws a layer on top of Australia |
127 | 148 | String geoJsonString = Util.readFromRawResource(this, R.raw.google); |
@@ -152,6 +173,25 @@ public class MainActivity extends AppCompatActivity |
152 | 173 | return super.onOptionsItemSelected(item); |
153 | 174 | } |
154 | 175 |
|
| 176 | + private AirMapInterface createMapWithTouchDisabled(AirMapViewTypes type) { |
| 177 | + if (type == AirMapViewTypes.NATIVE) { |
| 178 | + AirGoogleMapOptions options = new AirGoogleMapOptions(new GoogleMapOptions()); |
| 179 | + options.setTouchEnabled(false); |
| 180 | + AirMapInterface airMapInterface = mapViewBuilder.builder(type).withOptions(options).build(); |
| 181 | + return airMapInterface; |
| 182 | + } |
| 183 | + |
| 184 | + // case where it's not a native map, doesn't use AirGoogleMapOptions |
| 185 | + final AirMapInterface mapInterface = mapViewBuilder.builder(type).build(); |
| 186 | + mapInterface.setOnMapLoadedListener(new OnMapLoadedListener() { |
| 187 | + @Override |
| 188 | + public void onMapLoaded() { |
| 189 | + mapInterface.setTouchEnabled(false); |
| 190 | + } |
| 191 | + }); |
| 192 | + return mapInterface; |
| 193 | + } |
| 194 | + |
155 | 195 | @Override public void onCameraChanged(LatLng latLng, int zoom) { |
156 | 196 | appendLog("Map onCameraChanged triggered with lat: " + latLng.latitude + ", lng: " |
157 | 197 | + latLng.longitude); |
|
0 commit comments