
Google Map JavaScript API¬OGoogle´£¨Ñªº¤@²ÕAPI¡A¥i¥HÅý³]p®v¦Ûq©Î¶}µoGoogle Map¬ÛÃöªºÀ³¥Îµ{¦¡
Google Maps Javascript API¥Ø«eªºª©¥»¬O²Ä¤Tª©¡A©Ò¥H¤U±ªºµ{¦¡³£¬O¥H²Ä¤Tª©¬°¥D
¦pªG§Aª±¹L²Ä¤Gª©¡A²Ä¤Tª©¤w¤£»Ýn¨Æ¥ý¦VGoolge¥Ó½ÐKey¡A¦Ó¥i¥Hª½±µ¨Ï¥Î
n¨Ï¥ÎGoogle Map API¡An¥ý¦b<head>¤¤¸ü¤JGoogleMapAPI
±µµÛ¦b<body>¤¤·s¼W¤@ÓDIV¡A§@¬°¥Î¨ÓÅã¥Ü¦a¹Ïªº¤¸��
1 |
< DIV style = "WIDTH: 600px; HEIGHT: 600px" id = mapDiv ></ DIV > |
±µµÛ¦b<head>¤¤¡A¥[¤J¤U¦CJavaScript
01 |
<SCRIPT type=text/javascript> |
02 |
function initialize() { |
05 |
center: new google.maps.LatLng(24.80185, 120.97166), |
06 |
mapTypeId: google.maps.MapTypeId.ROADMAP |
08 |
var map = new google.maps.Map(document.getElementById( "mapDiv" ), myOptions); |
Google Mapªºªì©l¤Æ¤èªk¦p¤U
var map = new google.maps.Map( DOM¤¸¯À, Options);
¦b³o½d¨Ò¤¤¡AOptions±a¤J¤F3Ó¥²¶ñªº°Ñ¼Æ¡G
- zoom¡Gªì©l®É¦a¹ÏnÅã¥Üªº¤ñ¨Ò¤j¤p¡AȪº½d³ò¬°0~20
- center¡G¦a¹Ïªº¤¤¤ß®y¼Ð¡AȻݬ°google.maps.LatLngª«¥ó
- mapTypeId¡G¦a¹Ïªº§ÎºA¡A¦³4ºØ«¬ºA¥i¥H¿ï¾Ü¡A¤À§O¬°RoadMap(¦a¹Ï)¡BSatellite(½Ã¬P)¡BHybrid(¦a¹Ï©M½Ã¬P²V¦X)¡BTerain(¦a§Î¹Ï)

¦bOptions¤¤¥i¥H³]©w¦a¹Ï¤W¬O§_nÅã¥Ü¤@¨Ç±±¨î¶µ¡A³o¨Ç±±¨î¶µ°£scaleControl¹w³]¤£Åã¥Ü¥~¡A¨ä¥¦¹w³]³£·|Åã¥Ü
- mapTypeControl: true
- navigationControl : true
- scaleControl : false
- streetViewControl: true

google.maps.LatLng
google.maps.LatLng¬°Google Map API±M¥Îªº®y¼Ðª«¥ó¡A¥Î¤Q¶i¨î¨Óªí¥Ü¸g½n«×¡A«Å§i¤è¦¡¬°
1 |
var point = google.maps.LatLng(¤Q¶i¨î¸g«×, ¤Q¶i¨î½n«×); |
ªì©l¤Æ«á¥i¥H§Q¥Î.lat( )©M.lng( )¤èªk¨Ó¨ú±o¸g½n«×¡A¨Ò¦p
1 |
var point = new google.maps.LatLng( "24.80185" , "120.97166" ); |
2 |
alert( point.lat() + ", " + point.lng()); |
§¹¾ã½d¨Ò¦p¤U¡G
04 |
< meta name = "viewport" content = "initial-scale=1.0, user-scalable=no" > |
06 |
< script type = "text/javascript" > |
07 |
function initialize() { |
10 |
center: new google.maps.LatLng(24.80185, 120.97166), |
11 |
mapTypeId: google.maps.MapTypeId.ROADMAP |
13 |
var map = new google.maps.Map(document.getElementById("mapDiv"), myOptions); |
18 |
< body onload = "initialize()" > |
19 |
< div id = "mapDiv" style = "width: 400px; height: 400px;" ></ div > |
¤W±ªº½d¨Ò·f°tjQuery¥i¥H§ï¼g¬°
04 |
< script type = "text/javascript" src = "jquery.js" ></ script > |
06 |
< script type = "text/javascript" > |
10 |
center: new google.maps.LatLng(24.80185, 120.97166), |
11 |
mapTypeId: google.maps.MapTypeId.ROADMAP |
13 |
var map = new google.maps.Map( $('#mapDiv').get(0) , myOptions); |
19 |
< div id = "mapDiv" style = "width: 400px; height: 400px;" ></ div > |
³Ì«áªþ¤W¤@Ó½d¨Ò¡A¥i¥HÅý¨Ï¥ÎªÌ¦Ûq¦a¹Ïªº¤Ø¤o©MÅã¥Üªº¤ñ¨Ò¡A°õ¦æµe±¦p¤U¡G

½d¨Ò§¹¾ãµ{¦¡½X¦p¤U¡G
04 |
< script type = "text/javascript" src = "jquery.js" ></ script > |
06 |
< script type = "text/javascript" > |
10 |
center: new google.maps.LatLng(24.80185, 120.97166), |
11 |
mapTypeId: google.maps.MapTypeId.ROADMAP, |
12 |
navigationControl: false, |
14 |
streetViewControl: false, |
18 |
var map = new google.maps.Map($('#mapDiv').get(0), myOptions); |
21 |
$('#changeMapSizeBtn').click(function() { |
22 |
$('#mapDiv').css('width', $('#mapWidth').val()).css('height', $('#mapHeight').val()); |
23 |
map = new google.maps.Map($('#mapDiv').get(0), myOptions); |
27 |
$('#zoomChangeBtn').click(function() { |
28 |
var zoom = $('#mapZoom').val(); |
29 |
zoom = (zoom < 0 ) ? 0 : zoom; |
30 |
zoom = (zoom > 20) ? 20 : zoom; |
31 |
map.setZoom(parseInt(zoom)); |
40 |
¦a¹Ï¼e«×¡G< input id = "mapWidth" size = "5" type = "text" /> |
41 |
¦a¹Ï°ª«×¡G< input id = "mapHeight" size = "5" type = "text" /> |
42 |
< input id = "changeMapSizeBtn" type = "button" value = "§ó·s¦a¹Ï¤j¤p" /> |
44 |
¤ñ¨Ò< input id = "mapZoom" size = "5" type = "text" value = "15" />< input id = "zoomChangeBtn" type = "button" value = "§ó·s¤ñ¨Ò" /> |
46 |
< div id = "mapDiv" style = "width: 400px; height: 400px;" ></ div > |