Google地图接口API之Google地图 API 参考手册(七)

2022-11-12,,,,

Google 地图API 参考手册

地图

构造函数/对象 描述
Map() 在指定的 HTML 容器中创建新的地图,该容器通常是一个DIV元素。

叠加层

构造函数/对象 描述
Marker 创建一个标记。
MarkerOptions 标记的选项。由DirectionsRenderer渲染的所有标记都将使用这些选项。
MarkerImage A structure representing a Marker icon or shadow image
MarkerShape Defines the marker shape to use in determination of a marker's clickable region (type and coord)
Animation Specifies animations that can be played on a marker (bounce or drop)
InfoWindow Creates an info window
InfoWindowOptions Options for rendering the info window
Polyline Creates a polyline (contains path and stroke styles)
PolylineOptions Options for rendering the polyline
Polygon Creates a polygon (contains path and stroke+fill styles)
PolygonOptions Options for rendering the polygon
Rectangle Creates a rectangle (contains bounds and stroke+fill styles)
RectangleOptions Options for rendering the rectangle
Circle Creates a circle (contains center+radius and stroke+fill styles)
CircleOptions Options for rendering the circle
GroundOverlay  
GroundOverlayOptions  
OverlayView  
MapPanes  
MapCanvasProjection  

事件

构造函数/对象 描述
MapsEventListener It has no methods and no constructor. Its instances are returned from addListener(), addDomListener() and are eventually passed back to removeListener()
event Adds/Removes/Trigger event listeners
MouseEvent Returned from various mouse events on the map and overlays

控件集

构造函数/对象 描述
MapTypeControlOptions Holds options for modifying a control (position and style)
MapTypeControlStyle Specifies what kind of map control to display (Drop-down menu or buttons)
OverviewMapControlOptions Options for rendering of the overview map control (opened or collapsed)
PanControlOptions Options for rendering of the pan control (position)
RotateControlOptions Options for rendering of the rotate control (position)
ScaleControlOptions Options for rendering of the scale control (position and style)
ScaleControlStyle Specifies what kind of scale control to display
StreetViewControlOptions Options for rendering of the street view pegman control (position)
ZoomControlOptions Options for rendering of the zoom control (position and style)
ZoomControlStyle Specifies what kind of zoom control to display (large or small)
ControlPosition Specifies the placement of controls on the map

地图 API Map() 构造器:

定义和用法

Map() 构造器创建了一个新的地图并插入到指定的HTML元素中(<div> 元素)。


语法

new google.maps.Map(HTMLElement,MapOptions)

参数值

参数 描述
HTMLElement 规定要把地图放置在那个 HTML 元素中。
MapOptions 带有地图初始化变量/选项的 MapOptions 对象。

Map() 的方法

方法 返回值 描述
fitBounds(LatLngBounds) None 设置要包含给定边界的视口。
getBounds() LatLng,LatLng 返回当前视口的西南纬度/经度和东北纬度/经度。
getCenter() LatLng 返回地图的中心的纬度/经度。
getDiv() Node 返回包含地图的 DOM 对象。
getHeading() number 返回航拍图像的罗盘航向(支持 SATELLITE 和 HYBRID 地图类型)。
getMapTypeId() HYBRID ROADMAP SATELLITE TERRAIN 返回当前地图类型。
getProjection() Projection 返回当前 Projection(投影)。
getStreetView() StreetViewPanorama 返回绑定到地图的默认的 StreetViewPanorama。
getTilt() number 返回航拍图像的入射角度数(支持 SATELLITE 和 HYBRID 地图类型)。
getZoom() number 返回地图的当前缩放级别。
panBy(xnumber,ynumber) None 通过以像素计的给定距离改变地图的中心。
panTo(LatLng) None 改变地图的中心为给定的 LatLng。
panToBounds(LatLngBounds) None 将地图平移所需的最小距离以包含给定的 LatLngBounds。
setCenter(LatLng) None  
setHeading(number) None 设置航拍图像的罗盘方向(以度为单位进行测量),基本方向为北方。
setMapTypeId(MapTypeId) None 改变要显示的地图类型。
setOptions(MapOptions) None  
setStreetView(StreetViewPanorama) None 绑定一个 StreetViewPanorama 到地图上。
setTilt(number) None 设置航拍图像的入射角度数(支持 SATELLITE 和 HYBRID 地图类型)。
setZoom(number) None  

Map() 的属性

属性 类型 描述
controls Array.<MVCArray.<Node>> 要附加到地图上的额外控件。
mapTypes MapTypeRegistry 按字符串 ID 划分的 MapType 实例的注册表。
overlayMapTypes MVCArray.<MapType> 要叠加的额外地图类型。

Map() 的事件

事件 参数 描述
bounds_changed None 当可视区域范围更改时会触发此事件。
center_changed None 当地图 center(中心)属性更改时会触发此事件。
click MouseEvent 当用户点击地图(但不是点击标记或信息窗口)时会触发此事件。
dblclick MouseEvent 当用户双击地图时会触发此事件。请注意,触发此事件前还会触发点击事件。
drag None 当用户拖动地图时会反复触发此事件。
dragend None 当用户停止拖动地图时会触发此事件。
dragstart None 当用户开始拖动地图时会触发此事件。
heading_changed None 当地图 heading(方向)属性更改时会触发此事件。
idle None 当地图在平移或缩放之后变为闲置状态时会触发此事件。
maptypeid_changed None 当 mapTypeId 属性更改时会触发此事件。
mousemove MouseEvent 只要用户的鼠标在地图容器上移动,就会触发此事件。
mouseout MouseEvent 当用户的鼠标从地图容器上退出时会触发此事件。
mouseover MouseEvent 当用户的鼠标进入地图容器时会触发此事件。
projection_changed None 当投影更改时会触发此事件。
resize None 当地图(div)更改尺寸时会触发此事件。
rightclick MouseEvent 当用户右击地图时会触发此事件。
tilesloaded None 当可见图块载入完成后会触发此事件。
tilt_changed None 当地图 tilt(倾斜)属性更改时会触发此事件。
zoom_changed None 当地图 zoom(缩放)属性更改时会触发此事件。

Google地图接口API之Google地图 API 参考手册(七)的相关教程结束。

《Google地图接口API之Google地图 API 参考手册(七).doc》

下载本文的Word格式文档,以方便收藏与打印。