1010import android .widget .TextView ;
1111import android .widget .Toast ;
1212
13- import com .airbnb .android .airmapview .AirMapInterface ;
14- import com .airbnb .android .airmapview .AirMapMarker ;
15- import com .airbnb .android .airmapview .AirMapView ;
16- import com .airbnb .android .airmapview .AirMapViewTypes ;
17- import com .airbnb .android .airmapview .DefaultAirMapViewBuilder ;
18- import com .airbnb .android .airmapview .listeners .OnCameraChangeListener ;
19- import com .airbnb .android .airmapview .listeners .OnCameraMoveListener ;
20- import com .airbnb .android .airmapview .listeners .OnLatLngScreenLocationCallback ;
21- import com .airbnb .android .airmapview .listeners .OnInfoWindowClickListener ;
22- import com .airbnb .android .airmapview .listeners .OnMapClickListener ;
23- import com .airbnb .android .airmapview .listeners .OnMapInitializedListener ;
24- import com .airbnb .android .airmapview .listeners .OnMapMarkerClickListener ;
13+ import com .airbnb .android .airmapview .*;
14+ import com .airbnb .android .airmapview .listeners .*;
15+ import com .google .android .gms .maps .GoogleMapOptions ;
2516import com .google .android .gms .maps .model .LatLng ;
2617import com .google .android .gms .maps .model .Marker ;
2718
@@ -75,6 +66,15 @@ public class MainActivity extends ActionBarActivity
7566 }
7667 } else if (id == R .id .action_web_map ) {
7768 airMapInterface = mapViewBuilder .builder (AirMapViewTypes .WEB ).build ();
69+ } else if (id == R .id .action_web_map_no_touch || id == R .id .action_native_map_no_touch ) {
70+ try {
71+ airMapInterface = createMapWithTouchDisabled (id == R .id .action_web_map_no_touch ? AirMapViewTypes .WEB : AirMapViewTypes .NATIVE );
72+ } catch (UnsupportedOperationException e ) {
73+ Toast .makeText (this , "Sorry, native Google Maps are not supported by this device. " +
74+ "Please make sure you have Google Play Services installed." ,
75+ Toast .LENGTH_SHORT ).show ();
76+ }
77+
7878 } else if (id == R .id .action_clear_logs ) {
7979 textLogs .setText ("" );
8080 }
@@ -86,6 +86,25 @@ public class MainActivity extends ActionBarActivity
8686 return super .onOptionsItemSelected (item );
8787 }
8888
89+ private AirMapInterface createMapWithTouchDisabled (AirMapViewTypes type ) {
90+ if (type == AirMapViewTypes .NATIVE ) {
91+ AirGoogleMapOptions options = new AirGoogleMapOptions (new GoogleMapOptions ());
92+ options .setTouchEnabled (false );
93+ AirMapInterface airMapInterface = mapViewBuilder .builder (type ).withOptions (options ).build ();
94+ return airMapInterface ;
95+ }
96+
97+ // case where it's not a native map, doesn't use AirGoogleMapOptions
98+ final AirMapInterface mapInterface = mapViewBuilder .builder (type ).build ();
99+ mapInterface .setOnMapLoadedListener (new OnMapLoadedListener () {
100+ @ Override
101+ public void onMapLoaded () {
102+ mapInterface .setTouchEnabled (false );
103+ }
104+ });
105+ return mapInterface ;
106+ }
107+
89108 @ Override public void onCameraChanged (LatLng latLng , int zoom ) {
90109 appendLog ("Map onCameraChanged triggered with lat: " + latLng .latitude + ", lng: "
91110 + latLng .longitude );
0 commit comments