Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added setTouchEnabled to disable zoom, pan and drag. #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions library/src/main/assets/google_map.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
function stopTrackingUserLocation() {
GeoMarker.setMap(null);
}
function setTouchEnabled(enabled) {
map.setOptions({draggable: enabled, zoomControl: enabled, scrollwheel: enabled, disableDoubleClickZoom: !enabled});
}

function clearMarkers() {
for (var key in markers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ public AirGoogleMapOptions mapToolbarEnabled(boolean enabled) {
return this;
}

public AirGoogleMapOptions setTouchEnabled(boolean enabled) {
tiltGesturesEnabled(enabled);
rotateGesturesEnabled(enabled);
zoomGesturesEnabled(enabled);
scrollGesturesEnabled(enabled);
return this;
}

public Boolean getZOrderOnTop() {
return options.getZOrderOnTop();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,9 @@ public interface AirMapInterface {
* Remove GeoJson layer from map, if any.
*/
void clearGeoJsonLayer();
/**
* Set to whether to enable touch. If it's disabled then the user won't be allowed to drag, zoom or pan.
* @param enabled
*/
void setTouchEnabled(boolean enabled);
}
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ public void setMyLocationEnabled(boolean trackUserLocation) {
mapInterface.setMyLocationEnabled(trackUserLocation);
}

public void setTouchEnabled(boolean enabled) {
mapInterface.setTouchEnabled(enabled);
}

@Override public void onCameraChanged(LatLng latLng, int zoom) {
if (onCameraChangeListener != null) {
onCameraChangeListener.onCameraChanged(latLng, zoom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public void onMapReady(GoogleMap googleMap) {
if (onMapLoadedListener != null) {
onMapLoadedListener.onMapLoaded();
}

}
}
});
Expand Down Expand Up @@ -126,6 +127,10 @@ public void onInfoWindowClick(Marker marker) {
});
}

@Override public void setTouchEnabled(boolean enabled) {
googleMap.getUiSettings().setAllGesturesEnabled(enabled);
}

@Override public void setInfoWindowCreator(GoogleMap.InfoWindowAdapter adapter,
InfoWindowCreator creator) {
googleMap.setInfoWindowAdapter(adapter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ public void setOnMarkerClickListener(OnMapMarkerClickListener listener) {
// no-op
}

@Override
public void setTouchEnabled(boolean enabled) {
webView.loadUrl("javascript:setTouchEnabled(" + enabled + ");");
}

@Override public <T> void addPolyline(AirMapPolyline<T> polyline) {
try {
JSONArray array = new JSONArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com.airbnb.android.airmapview.listeners.OnMapInitializedListener;
import com.airbnb.android.airmapview.listeners.OnMapMarkerClickListener;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;

import org.json.JSONException;

Expand Down
6 changes: 3 additions & 3 deletions sample/src/main/res/menu/menu_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
tools:context=".MainActivity">

<item android:id="@+id/action_native_map"
android:title="Use Native Map"
android:orderInCategory="100"
app:showAsAction="never"/>
android:title="Use Native Map"
android:orderInCategory="100"
app:showAsAction="never"/>

<item android:id="@+id/action_google_web_map"
android:title="Use Google Web Map"
Expand Down