use of com.google.android.libraries.maps.model.CameraPosition in project google-maps by capacitor-community.
the class CapacitorGoogleMaps method create.
@PluginMethod()
public void create(PluginCall call) {
final Integer width = call.getInt("width", DEFAULT_WIDTH);
final Integer height = call.getInt("height", DEFAULT_HEIGHT);
final Integer x = call.getInt("x", 0);
final Integer y = call.getInt("y", 0);
final Float zoom = call.getFloat("zoom", DEFAULT_ZOOM);
final Double latitude = call.getDouble("latitude");
final Double longitude = call.getDouble("longitude");
final boolean liteMode = call.getBoolean("enabled", false);
final CapacitorGoogleMaps ctx = this;
getBridge().getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
LatLng latLng = new LatLng(latitude, longitude);
CameraPosition cameraPosition = new CameraPosition.Builder().target(latLng).zoom(zoom).build();
GoogleMapOptions googleMapOptions = new GoogleMapOptions();
googleMapOptions.camera(cameraPosition);
googleMapOptions.liteMode(liteMode);
if (mapViewParentId != null) {
View viewToRemove = ((ViewGroup) getBridge().getWebView().getParent()).findViewById(mapViewParentId);
if (viewToRemove != null) {
((ViewGroup) getBridge().getWebView().getParent()).removeViewInLayout(viewToRemove);
}
}
FrameLayout mapViewParent = new FrameLayout(getBridge().getContext());
mapViewParentId = View.generateViewId();
mapViewParent.setId(mapViewParentId);
mapView = new MapView(getBridge().getContext(), googleMapOptions);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(getScaledPixels(width), getScaledPixels(height));
lp.topMargin = getScaledPixels(y);
lp.leftMargin = getScaledPixels(x);
mapView.setLayoutParams(lp);
mapViewParent.addView(mapView);
((ViewGroup) getBridge().getWebView().getParent()).addView(mapViewParent);
mapView.onCreate(null);
mapView.onStart();
mapView.getMapAsync(ctx);
}
});
call.resolve();
}
use of com.google.android.libraries.maps.model.CameraPosition in project android-samples by googlemaps.
the class CameraDemoActivity method onTiltLess.
/**
* Called when the tilt less button (the one with the \) is clicked.
*/
public void onTiltLess(View view) {
if (!checkReady()) {
return;
}
CameraPosition currentCameraPosition = map.getCameraPosition();
float currentTilt = currentCameraPosition.tilt;
float newTilt = currentTilt - 10;
newTilt = (newTilt > 0) ? newTilt : 0;
CameraPosition cameraPosition = new CameraPosition.Builder(currentCameraPosition).tilt(newTilt).build();
changeCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
use of com.google.android.libraries.maps.model.CameraPosition in project android-samples by googlemaps.
the class CameraDemoActivity method onTiltMore.
/**
* Called when the tilt more button (the one with the /) is clicked.
*/
public void onTiltMore(View view) {
if (!checkReady()) {
return;
}
CameraPosition currentCameraPosition = map.getCameraPosition();
float currentTilt = currentCameraPosition.tilt;
float newTilt = currentTilt + 10;
newTilt = (newTilt > 90) ? 90 : newTilt;
CameraPosition cameraPosition = new CameraPosition.Builder(currentCameraPosition).tilt(newTilt).build();
changeCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
Aggregations