Add restriction option for google map options (#36774)

* Add restriction option for google map options.

* Add comments from original Google Maps JS API documentation and links to it.
This commit is contained in:
vladimir
2019-07-10 13:14:56 -07:00
committed by Armando Aguirre
parent 718f6ea35d
commit ee4315d618
2 changed files with 38 additions and 1 deletions
+4
View File
@@ -11,6 +11,10 @@ let mapOptions: google.maps.MapOptions = {
position: google.maps.ControlPosition.RIGHT_TOP
},
gestureHandling: 'cooperative',
restriction: {
latLngBounds: { east: 180, west: -180, north: 85, south: -85 },
strictBounds: true
},
scrollwheel: true,
styles: [
{
+34 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for Google Maps JavaScript API 3.36
// Type definitions for Google Maps JavaScript API 3.37
// Project: https://developers.google.com/maps/
// Definitions by: Folia A/S <http://www.folia.dk>,
// Chris Wrench <https://github.com/cgwrench>,
@@ -13,6 +13,7 @@
// Michael Gauthier <https://github.com/gauthierm>
// Colin Doig <https://github.com/captain-igloo>
// Dmitry Demensky <https://github.com/demensky>
// Vladimir Dashukevich <https://github.com/life777>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.7
@@ -192,6 +193,13 @@ declare namespace google.maps {
* in the v3.22 Map Controls}.
*/
panControlOptions?: PanControlOptions;
/**
* Defines a boundary that restricts the area of the map accessible to users.
* When set, a user can only pan and zoom while the camera view stays inside the
* limits of the boundary.
* @see {@link https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions.restriction Maps JavaScript API}
*/
restriction?: MapRestriction;
/** The enabled/disabled state of the Rotate control. */
rotateControl?: boolean;
/** The display options for the Rotate control. */
@@ -314,6 +322,31 @@ declare namespace google.maps {
position?: ControlPosition;
}
/**
* A restriction that can be applied to the Map. The map's viewport will not
* exceed these restrictions.
* @see {@link https://developers.google.com/maps/documentation/javascript/reference/map#MapRestriction Maps JavaScript API}
*/
interface MapRestriction {
/**
* When set, a user can only pan and zoom inside the given bounds.
* Bounds can restrict both longitude and latitude, or can restrict
* latitude only. For latitude-only bounds use west and east longitudes
* of -180 and 180, respectively.
* @see {@link https://developers.google.com/maps/documentation/javascript/reference/map#MapRestriction.latLngBounds Maps JavaScript API}
*/
latLngBounds: LatLngBounds | LatLngBoundsLiteral;
/**
* By default bounds are relaxed, meaning that a user can zoom out
* until the entire bounded area is in view. Bounds can be made more
* restrictive by setting the strictBounds flag to true. This reduces
* how far a user can zoom out, ensuring that everything outside of the
* restricted bounds stays hidden.
* @see {@link https://developers.google.com/maps/documentation/javascript/reference/map#MapRestriction.strictBounds Maps JavaScript API}
*/
strictBounds?: boolean;
}
/** Options for the rendering of the scale control. */
interface ScaleControlOptions {
/** Style id. Used to select what style of scale control to display. */