Movatterモバイル変換


[0]ホーム

URL:


w3resource
w3resource logo

Map options, properties, controls

google.maps.Map class - constructor

Constructor: Map(mapDiv:Node, opts?: MapOptions )

The constructor creates a new map inside the given HTML container, which is typically a reference to a <div>. TheMapOptions object contains some properties that control the behavior of this map container.

Here we are referring theintroductory map once again, see the mapOptions part.

<!DOCTYPE html><html><head><meta name="viewport" content="initial-scale=1.0.0, user-scalable=no" /><style type="text/css">   html { height: 100% }   body { height: 100%; margin: 0; padding: 0 }   #map-canvas { height: 100% }</style><script type="text/javascript"src="https://maps.googleapis.com/maps/api/js?key=API_KEY&sensor=true"></script><script type="text/javascript">   function initialize()    {  var mapOptions = {  center: new google.maps.LatLng(52.5167, 13.3833),  zoom: 10,   };var map = new google.maps.Map (document.getElementById("map-canvas"),  mapOptions ;   }google.maps.event.addDomListener(window, 'load', initialize); </script> </head> <body> <div id="map-canvas"></div> </body> </html>

google.maps.MapOptions object specification

In this page, we have discussed all the properties of the above object except streetView, streetViewControl and streetViewControlOptions properties which will be discussed in a separate page. In almost all properties there are examples with online edit and practice facilities.

Properties

The following table shows the properties of the Map object:

Property TypeDescription
backgroundColorstring

Use the backgroundColor property for the background of the Map <div> containing the map. This color will be visible when the tiles have not yet loaded as the user pans. The backgroundColor property cannot be changed dynamically, it must be set during initialization of the map.

center

LatLng

Determines the initial center of the map. Required.

Constructor : LatLng(lat:number, lng:number, noWrap?:boolean)

Creates a LatLng object (google.maps.LatLng class) representing a geographic point.
Latitude is specified in degrees within the range [-90, 90].
Longitude is specified in degrees within the range [-180, 180].
Set no Wrap to true to enable values outside of this range.

disableDefaultUIboolean

Using disableDefaultUI property you can enable or disable all default UI (user interface). Setting property value true you can still enable these controls individually. The default value is false.

disableDoubleClickZoomboolean

Using disableDoubleClickZoom property you can enable or disable zoom and center on double click. The default value isfalse.

draggableboolean

Using draggable property you can prevent the map from being dragged. By default, dragging is enabled.

draggableCursorstringUsing draggableCursor property, the name (e.g. move,no-drop,help etc.) or url of the cursor to display, when mousing over a draggable map.
draggingCursorstring

Using draggingCursor, the name (e.g. move,no-drop,help etc.) or url of the cursor to display when the map is being dragged.

headingnumberThe heading for aerial imagery in degrees measured clockwise from cardinal direction North. Headings are snapped to the nearest available angle for which imagery is available.
keyboardShortcutsboolean

keyboardShortcuts property enables or disables map from being controlled by the keyboard (e.g. arrow keys). The default value is true.

mapMakerbooleanTrue if Map Maker tiles should be used instead of regular tiles.
mapTypeControlboolean

The mapTypeControl property enables or disables the map type (Map, Satellite) control, positioned at the top right corner on the map. The default value is true.

mapTypeControlOptionsMapTypeControlOptionsThe initial display options for the Map type control.Go to google. maps. MapTypeControlOptions object specification
mapTypeIdMapTypeIdThe initial Map mapTypeId. The default value is ROADMAP.Go to google.maps.MapTypeId class
maxZoomnumberThe maximum zoom level which will be displayed on the map. If omitted, or set to null, the maximum zoom from the current map type is used instead.
minZoomnumberThe minimum zoom level which will be displayed on the map. If omitted, or set to null, the minimum zoom from the current map type is used instead.
noClearboolean If true, do not clear the contents of the Map div. The default value of noClear is false.
overviewMapControlbooleanThe enabled/disabled state of the Overview Map control.
overviewMapControlOptionsOverviewMapControlOptionsThe display options for the Overview Map control.Go to google.maps.OverviewMapControlOptions object specification
panControlbooleanThe enabled/disabled state of the Pan control.
panControlOptionsPanControlOptionsThe display options for the Pan control.Go to google.maps.PanControlOptions object specification
rotateControlbooleanThe display options for the Rotate control. rotateControl enables/disables the appearance of a Rotate control for controlling the orientation of 45° imagery. By default, the control's appearance is determined by the presence or absence of 45° imagery for the given map type at the current zoom and location. You may alter the control's behavior by setting the map's rotateControlOptions to specify the RotateControlOptions to use (though you cannot make the control appear if no 45° imagery is currently available).
rotateControlOptionsRotateControlOptionsThe initial enabled/disabled state of the Scale control.Go to google.maps.RotateControlOptions object specification
scaleControlboolean

scaleControl property enabled/disabled state of the Scale control that provides a map scale. By default, this control is not visible.

scaleControlOptionsScaleControlOptionsThe initial display options for the Scale control.Go to google.maps.ScaleControlOptions object specification
scrollwheelboolean

Disables scrollwheel (mouse wheel) zooming on the map when it is false. The property is enabled by default.

streetViewStreetViewPanoramaA StreetViewPanorama to display when the Street View pegman is dropped on the map. If no panorama is specified, a default StreetViewPanorama will be displayed in the map's div when the pegman is dropped.
streetViewControlbooleanThe initial enabled/disabled state of the Street View Pegman control. This control is part of the default UI, and should be set to false when displaying a map type on which the Street View road overlay should not appear (e.g. a non-Earth map type).
streetViewControlOptionsStreetViewControlOptionsThe initial display options for the Street View Pegman control.
stylesArray.<MapTypeStyle>Styles to apply to each of the default map types. Note that for Satellite/Hybrid and Terrain modes, these styles will only apply to labels and geometry.
tiltnumberControls the automatic switching behavior for the angle of incidence of the map. The only allowed values are 0 and 45.
zoomnumberThe initial Map zoom level. Required.
zoomControlbooleanThe enabled/disabled state of the Zoom control.
zoomControlOptionsZoomControlOptionsThe display options for the Zoom control.Go to google.maps.ZoomControlOptions object specification

google.maps.MapTypeControlOptions object specification

Following options are available for rendering the map type control :

Property TypeDescription
mapTypeIdsArray.<MapTypeId>|Array.<string>

An array containing the IDs of map types, available in the control.

position

ControlPosition

Position id. Specify the position of the control on the map. The default position is TOP_RIGHT.Go to google.maps.ControlPosition class

styleMapTypeControlStyleStyle id. Specify the style of map type control to display.Go to google.maps.MapTypeControlStyle class

ControlPosition class

This class contains the placement of controls on the map.

Constant:The following table describes the constants of the ControlPosition class.

Constant Description
BOTTOM_CENTERSet the map type control position in the center of the bottom row.
BOTTOM_LEFT

Set the map type control position in the bottom left and flow towards the middle. Elements are positioned to the right of the Google logo.

BOTTOM_RIGHTSet the map type control position in the bottom right and flow towards the middle. Elements are positioned to the left of the copyrights.
LEFT_BOTTOMSet the map type control position on the left, above bottom-left elements, and flow upwards.
LEFT_CENTERSet the map type control position in the center of the left side.
LEFT_TOPSet the map type control position on the left, below top-left elements, and flow downwards.
RIGHT_BOTTOMSet the map type control position on the right, above bottom-right elements, and flow upwards.
RIGHT_CENTERSet the map type control position in the center of the right side.
RIGHT_TOPSet the map type control position on the right, below top-right elements, and flow downwards.
TOP_CENTERSet the map type control position in the center of the top row.
TOP_LEFTSet the map type control position in the top left and flow towards the middle.
TOP_RIGHTSet the map type control position in the top right and flow towards the middle.

MapTypeControlStyle class

This class contains the style of controls on the map.

Constant :The following table describes the constants of the MapTypeControlStyle class.

Constant Description
DEFAULTSet the map type control position in the center of the bottom row.
DROPDOWN_MENU

Set a dropdown menu for the screen realestate conscious.

HORIZONTAL_BARSet the standard horizontal radio buttons bar.

google.maps.MapTypeId class

This class contains the identifiers for common MapTypes.

Constant:The following table describes the constants of the MapTypeId class.

Constant Description
HYBRIDShows a transparent layer of major streets on satellite images.
ROADMAP

This is the default map type. Shows normal street/road map.

SATELLITEShows satellite images only.
TERRAINShows normal street/road map based on terrain and vegetation information.

google.maps.OverviewMapControlOptions object specification

Options for the rendering of the Overview Map control.

Property TypeDescription
openedbooleanSets the control display in opened mode (true) or collapsed (false) mode. By default, the control is closed (false).

google.maps.PanControlOptions object specification

Following options are available for rendering the pan control.

Property TypeDescription
position

ControlPosition

Position id. Used to specify the position of the control on the map. The default position is TOP_RIGHT.Go to google.maps.ControlPosition class

google.maps.ControlPosition class

This class contains the placement of controls on the map.

Constant:The following table describes the constants of the ControlPosition class.

Constant Description
BOTTOM_CENTERSet the panControl position in the center of the bottom row.
BOTTOM_LEFT

Set the panControl control position in the bottom left and flow towards the middle. Elements are positioned to the right of the Google logo.

BOTTOM_RIGHTSet the panControl control position in the bottom right and flow towards the middle. Elements are positioned to the left of the copyrights.
LEFT_BOTTOMSet the panControl control position on the left, above bottom-left elements, and flow upwards.
LEFT_CENTERSet the panControl control position in the center of the left side.
LEFT_TOPSet the panControl control position on the left, below top-left elements, and flow downwards.
RIGHT_BOTTOMSet the panControl control position on the right, above bottom-right elements, and flow upwards.
RIGHT_CENTERSet the panControl control position in the center of the right side.
RIGHT_TOPSet the panControl control position on the right, below top-right elements, and flow downwards.
TOP_CENTERSet the panControl control position in the center of the top row.
TOP_LEFTSet the panControl control position in the top left and flow towards the middle.
TOP_RIGHTSet the panControl control position in the top right and flow towards the middle.

google.maps.RotateControlOptions object specification

Following options are available for rendering the rotate control.

Property TypeDescription
position

ControlPosition

Position id. Used to specify the position of the control on the map. The default position is TOP_LEFT..Go to google.maps.ControlPosition class

google.maps.ControlPosition class

This class contains the placement of controls on the map.

Constant:The following table describes the constants of the ControlPosition class.

Constant Description
BOTTOM_CENTERSet the rotateControl position in the center of the bottom row.
BOTTOM_LEFT

Set the rotateControl control position in the bottom left and flow towards the middle. Elements are positioned to the right of the Google logo.

BOTTOM_RIGHTSet the rotateControl control position in the bottom right and flow towards the middle. Elements are positioned to the left of the copyrights.
LEFT_BOTTOMSet the rotateControl control position on the left, above bottom-left elements, and flow upwards.
LEFT_CENTERSet the rotateControl control position in the center of the left side.
LEFT_TOPSet the rotateControl control position on the left, below top-left elements, and flow downwards.
RIGHT_BOTTOMSet the rotateControl control position on the right, above bottom-right elements, and flow upwards.
RIGHT_CENTERSet the rotateControl control position in the center of the right side.
RIGHT_TOPSet the rotateControl control position on the right, below top-right elements, and flow downwards.
TOP_CENTERSet the rotateControl control position in the center of the top row.
TOP_LEFTSet the rotateControl control position in the top left and flow towards the middle.
TOP_RIGHTSet the rotateControl control position in the top right.

google.maps.ScaleControlOptions object specification

The ScaleControlOptions object contains options for displaying the scale control.

Property TypeDescription
position

ControlPosition

Specify the position of the control on the map. The default position is BOTTOM_LEFT when google.maps.visualRefresh is set to false. When google.maps.visualRefresh is true the scale control will be fixed at the BOTTOM_RIGHT.Go to google.maps.ControlPosition class

styleMapTypeControlStyleThe property is used to select what style of scale control to display.

google.maps.ControlPosition class

This class contains the placement of controls on the map.

Constant:The following table describes the constants of the ControlPosition class.

Constant Description
BOTTOM_CENTERSet the scaleControl position in the center of the bottom row.
BOTTOM_LEFT

Set the scaleControl control position in the bottom left and flow towards the middle.

BOTTOM_RIGHTSet the scaleControl control position in the bottom right and flow towards the middle. Elements are positioned to the left of the copyrights.
LEFT_BOTTOMSet the scaleControl control position on the left, above bottom-left elements, and flow upwards.
LEFT_CENTERSet the scaleControl control position in the center of the left side.
LEFT_TOPSet the scaleControl control position on the left, below top-left elements, and flow downwards.
RIGHT_BOTTOMSet the scaleControl control position on the right, above bottom-right elements, and flow upwards.
RIGHT_CENTERSet the scaleControl control position in the center of the right side.
RIGHT_TOPSet the scaleControl control position on the right, below top-right elements, and flow downwards.
TOP_CENTERSet the scaleControl control position in the center of the top row.
TOP_LEFTSet the scaleControl control position in the top left and flow towards the middle.
TOP_RIGHTSet the scaleControl control position in the top right and flow towards the middle.

Identifiers for common MapTypesControls.

Constant Description
DEFAULTSet the map type control position in the center of the bottom row.

google.maps.ZoomControlOptions object specification

The ScaleControlOptions object contains options for displaying the scale control.

Property TypeDescription
position

ControlPosition

Specify the position of the control on the map. The default position is BOTTOM_LEFT when google.maps.visualRefresh is set to false. When google.maps.visualRefresh is true the scale control will be fixed at the BOTTOM_RIGHT.Go to google.maps.ControlPosition class

styleMapTypeControlStyleThe property is used to select what style of scale control to display.Go to google.maps.ZoomControlStyle class

google.maps.ControlPosition class

This class contains the placement of controls on the map.

Constant Description
BOTTOM_CENTERSet the ZoomControl position in the center of the bottom row.
BOTTOM_LEFT

Set the ZoomControl control position in the bottom left.

BOTTOM_RIGHTSet the ZoomControl control position in the bottom right and flow towards the middle. Elements are positioned to the left of the copyrights.
LEFT_BOTTOMSet the ZoomControl control position on the left, above bottom-left elements, and flow upwards.
LEFT_CENTERSet the ZoomControl control position in the center of the left side.
LEFT_TOPSet the ZoomControl control position on the left, below top-left elements, and flow downwards.
RIGHT_BOTTOMSet the ZoomControl control position on the right, above bottom-right elements, and flow upwards.
RIGHT_CENTERSet the ZoomControl control position in the center of the right side.
RIGHT_TOPSet the ZoomControl control position on the right, below top-right elements, and flow downwards.
TOP_CENTERSet the ZoomControl control position in the center of the top row.
TOP_LEFTSet the ZoomControl control position in the top left and flow towards the middle.
TOP_RIGHTSet the ZoomControl control position in the top right.

google.maps.ZoomControlStyle class

The following sections related to the ZoomControlStyle class.

Constant:The following table describes the constants of the ZoomControlStyle class.

Constant Description
DEFAULTThe default zoom control. The control which DEFAULT maps to will vary according to map size and other factors. It may change in future versions of the API.
LARGE

Displays a larger zoom control, in addition to +/- buttons.

SMALLDisplays a small control with buttons to zoom in and out.

Previous: YouTube API Tutorial
Next: Creating your first app with Flickr API



Follow us onFacebook andTwitter for latest update.






[8]ページ先頭

©2009-2025 Movatter.jp