GMap (Version 1)-GoogleMaps/API/doc/ClassReference/01-GMap-N☆E 学習帳

[ リロード ]   [ ソース ]  [ トップ | 一覧 | 単語検索 | 最新 | バックアップ | ヘルプ ]

Counter: 6137, today: 8, yesterday: 2

GMap (Version 1)

http://www.google.com/apis/maps/docu­mentation/

An instance of GMap represents a single map on the page. See the discussion above for more information.

Constructor

Constructor Description
GMap(container, mapTypes?, width?, height?) Creates a new map inside of the given HTML container, which is typically a div element. We use the default set of map types ([G_MAP_TYPE, G_SATELLITE_TYPE]) unless a different set is specified. Likewise, we use the size of the container to determine the map width and height unless a width and height are explicitly specified.

 

var map = new GMap(document.getElementById("map"));

myTypesはマップとサテライト、どちらで表示するかを設定。
width、heightはここでは設定せず、divタグのスタイルでの設定する場合が多いようです。

var map = new GMap(document.getElementById("map"),[G_SATELLITE_TYPE],500,300);
divタグのスタイルはなし
以下にサンプルファイル

http://never-ever.info/googlemaps/gm­ap_c.htm (別窓)
サイズ指定が効いていないみたい。なぜ?
Googleのロゴが左上に??

 

Methods

Configuration

Method Description
enableDragging() Enables dynamic dragging (enabled by default)
disableDragging() Disables dynamic dragging
draggingEnabled() Returns true if dynamic dragging is enabled
enableInfoWindow() Enables the popup info windows on this map (enabled by default)
disableInfoWindow() Disables the popup info windows on this map
infoWindowEnabled() Returns true if the popup info windows are enabled on this map

 

map.disableDragging();
ドラッグを不許可に
以下がサンプル

http://never-ever.info/googlemaps/gm­ap_disabledragging.htm (別窓)

上のファイルに次の1行を追加
alert(map.draggingEnabled());
draggingEnabledの返り値をチェック、「false」と表示されるはず。

http://never-ever.info/googlemaps/gm­ap_draggingenabled.htm (別窓)

 

Controls

addControl(control) Adds the given map control to this map
removeControl(control) Removes the given map control from this map

 
addControl については GoogleMaps/API/doc/APIoverview/21-Controls へ

GLargeMapControl
GSmallMapControl
GSmallZoomControl
GMapTypeControl
GScaleControl ←これもあるみたいスケールバー

addControlで5つ(?)のコントローラークラスがあるみたい

オブジェクト.addControl(new GLargeMapControl());
↑こんな感じで利用

 

State

Method Description
getCenterLatLng() Returns the center point of the map viewport in lat/lng coordinates
getBoundsLatLng() Returns the lat/lng bounds of the map viewport
getSpanLatLng() Returns the width and height of the map viewport in latitude/longitude ticks
getZoomLevel() Returns the integer zoom level of the map
centerAtLatLng(latLng) Centers the map at the given lat/lng GPoint
recenterOrPanToLatLng(latLng) Centers the map at the given lat/lng GPoint, doing a fluid pan to the GPoint if it is within the current map viewport
zoomTo(zoomLevel) Zooms to the given integer zoom level, ignoring the request if the given zoom level is outside the bounds of the current map type
centerAndZoom(latLng, zoomLevel) Atomically centers and zooms the map. Useful to initialize the map with an initial center and zoom level, as in the examples above.
getMapTypes() Returns an array of map types supported by this map (e.g., G_MAP_TYPE and G_SATELLITE_TYPE)
getCurrentMapType() Returns the map type currently in use (e.g., G_MAP_TYPE or G_SATELLITE_TYPE)
setMapType(mapType) Switches this map to the given map type (e.g., G_MAP_TYPE or G_SATELLITE_TYPE)

 
上記のget系メソッドを下のサンプルファイルで地図の下に表示
http://never-ever.info/googlemaps/gm­ap_methods_state.htm

getMapTypes()、getCurrentMapType()はオブジェクトを返します。
getMapTypes()はサポートしているマップタイプを返すが、上記のファイルでは4つあるようだが、マップ・サテライト・デュアルのほかに何が?
このオブジェクトが何かを見る方法は?

 

Overlays

Method Description
addOverlay(overlay) Adds the given overlay object (e.g., GMarker or GPolyline) to the map
removeOverlay(overlay) Removes the given overlay object from the map
clearOverlays() Removes all of the overlays from the map

 

Info Window

Method Description
openInfoWindow(latLng, htmlElem, pixelOffset?, onOpenFn?, onCloseFn?) Displays the info window with the given HTML content at the given lat/lng point. htmlElem should be an HTML DOM element. If pixelOffset (GSize) is given, we offset the info window by that number of pixels, which lets users place info windows above markers and other overlays. If onOpenFn is given, we call the function when the window is displayed, and we call onCloseFn when the window is closed.
openInfoWindowHtml(marker, htmlStr, pixelOffset?, onOpenFn?, onCloseFn?) Like openInfoWindow, but takes an HTML string rather than an HTML DOM element
openInfoWindowXslt(marker, xmlElem, xsltUri, pixelOffset?, onOpenFn?, onCloseFn?) Like openInfoWindow, but takes an XML element and the URI of an XSLT document to produce the content of the info window. The first time a URI is given, it is downloaded with GXmlHttp and subsequently cached.
showMapBlowup(point, zoomLevel?, mapType?, pixelOffset?, onOpenFn?, onCloseFn?)) Shows a blowup of the map at the given lat/lng GPoint. We use a default zoom level of 1 and the current map type if the zoomLevel and mapType parameters are not given.
closeInfoWindow() Closes the info window if it is open

 

Events

Event Arguments Description
click overlay, point Triggered when the user clicks on the map or on an overlay on the map. If the click was on an overlay, the overlay is passed as an argument to the event handler. Otheriwse, we pass in the lat/lng point that was clicked on the map.
move none Triggered when the map is moving. This event is triggered continuously as the map is dragged.
movestart none Triggered at the beginning of a continuous pan/drag movement. This event is not triggered when the map moves discretely.
moveend none Triggered at the end of a discrete or continuous map movement. This event is triggered once at the end of a continuous pan.
zoom oldZoomLevel, newZoomLevel Triggered after the map zoom level changes
maptypechanged none Triggered after the map type (e.g., Map or Satellite) changes
infowindowopen none Triggered after the info window is displayed
infowindowclose none Triggered after the info window is closed
addoverlay overlay Triggered after an overlay is added to the map
removeoverlay overlay Triggered after an overlay is removed from the map. Not triggered if clearOverlays is called -- see the clearoverlays event below.
clearoverlays none Triggered after all overlays are cleared from the map