{"record":{"id":"1eb2be4d5f89606f","repo":"microg/GmsCore","slug":"tilt-needs-to-be-between-0-and-90-inclusive","errorCode":null,"errorMessage":"Tilt needs to be between 0 and 90 inclusive","messagePattern":"Tilt needs to be between 0 and 90 inclusive","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"play-services-maps/src/main/java/com/google/android/gms/maps/model/CameraPosition.java","lineNumber":89,"sourceCode":"     * @param zoom    Zoom level at target. See {@link #zoom} for details of restrictions.\n     * @param tilt    The camera angle, in degrees, from the nadir (directly down). See\n     *                {@link #tilt} for details of restrictions.\n     * @param bearing Direction that the camera is pointing in, in degrees clockwise from north.\n     *                This value will be normalized to be within 0 degrees inclusive and 360\n     *                degrees exclusive.\n     * @throws NullPointerException     if {@code target} is {@code null}\n     * @throws IllegalArgumentException if {@code tilt} is outside range of {@code 0} to {@code 90}\n     *                                  degrees inclusive\n     */\n    public CameraPosition(LatLng target, float zoom, float tilt, float bearing)\n            throws NullPointerException, IllegalArgumentException {\n        if (target == null) {\n            throw new NullPointerException(\"null camera target\");\n        }\n        this.target = target;\n        this.zoom = zoom;\n        if (tilt < 0 || 90 < tilt) {\n            throw new IllegalArgumentException(\"Tilt needs to be between 0 and 90 inclusive\");\n        }\n        this.tilt = tilt;\n        if (bearing <= 0) {\n            bearing += 360;\n        }\n        this.bearing = bearing % 360;\n    }\n\n    /**\n     * Creates a builder for a camera position.\n     */\n    public static Builder builder() {\n        return new Builder();\n    }\n\n    /**\n     * Creates a builder for a camera position, initialized to a given position.\n     */","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-maps/src/main/java/com/google/android/gms/maps/model/CameraPosition.java#L71-L107","documentation":"The CameraPosition(LatLng, float, float, float) constructor throws IllegalArgumentException when the tilt argument is outside the range 0 to 90 degrees inclusive. Tilt controls the viewing angle from directly overhead (0) to horizontally along the ground (90), and values beyond 90 are not representable by the map renderer. The check runs after the null-target check, so a valid non-null target is required first.","triggerScenarios":"Calling new CameraPosition(target, zoom, tilt, bearing) with tilt < 0 or tilt > 90, e.g. computing tilt from a gesture, sensor, or animation interpolation that overshoots the range, or passing a fractional/interpolated value like 90.5 during camera animation.","commonSituations":"Camera animation code that lerps between two tilts and slightly overshoots the endpoint due to floating-point math; UI sliders without clamping that let users enter values above 90; porting code from other map SDKs that allow steeper angles.","solutions":["Clamp the tilt value into [0, 90] with Math.max(0f, Math.min(90f, tilt)) before constructing the CameraPosition.","If tilt comes from user input or animation, normalize it at the source (slider bounds, interpolator output).","Check the numeric range before calling the constructor and reject or adjust out-of-range values."],"exampleFix":"// before\nfloat tilt = interpolateTilt(t); // may exceed 90\nCameraPosition pos = new CameraPosition(target, 15f, tilt, 0f);\n\n// after\nfloat tilt = Math.max(0f, Math.min(90f, interpolateTilt(t)));\nCameraPosition pos = new CameraPosition(target, 15f, tilt, 0f);","handlingStrategy":"validation","validationCode":"if (tilt < 0f || tilt > 90f) tilt = Math.max(0f, Math.min(90f, tilt));","typeGuard":"float clampTilt(float t) { return Math.max(0f, Math.min(90f, t)); }","tryCatchPattern":"try {\n    CameraPosition pos = new CameraPosition(target, zoom, tilt, bearing);\n} catch (IllegalArgumentException e) {\n    CameraPosition pos = new CameraPosition(target, zoom, clampTilt(tilt), bearing);\n}","preventionTips":["Clamp interpolated or animated tilt values at the point of use.","Constrain UI sliders/input to 0..90.","Remember other SDKs may allow different tilt ranges; normalize when porting."],"tags":["maps","android","range-check","camera"],"backgroundTag":"argument-out-of-range","analyzedSha":"157c9d86ac46c195a86c2f15ab55c84036223f95","analyzedAt":"2026-09-06T17:27:33.892Z","contentChangedAt":"2026-09-06T17:27:33.892Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}