01 | var myLatlng = new google.maps.LatLng(-25.363882,131.044922); |
02 | var myOptions = { |
03 | zoom: 4, |
04 | center: myLatlng, |
05 | mapTypeId: google.maps.MapTypeId.ROADMAP |
06 | } |
07 |
08 | var map = new google.maps.Map(document.getElementById( "map_canvas" ), myOptions); |
09 |
10 | var contentString = '<div id="content">' + |
11 | '<div id="siteNotice">' + |
12 | '</div>' + |
13 | '<h1 id="firstHeading" class="firstHeading">Uluru</h1>' + |
14 | '<div id="bodyContent">' + |
15 | '<p><b>Uluru</b>, also referred to as <b>Ayers Rock</b>, is a large ' + |
16 | 'sandstone rock formation in the southern part of the ' + |
17 | 'Northern Territory, central Australia. It lies 335 km (208 mi) ' + |
18 | 'south west of the nearest large town, Alice Springs; 450 km ' + |
19 | '(280 mi) by road. Kata Tjuta and Uluru are the two major ' + |
20 | 'features of the Uluru - Kata Tjuta National Park. Uluru is ' + |
21 | 'sacred to the Pitjantjatjara and Yankunytjatjara, the ' + |
22 | 'Aboriginal people of the area. It has many springs, waterholes, ' + |
23 | 'rock caves and ancient paintings. Uluru is listed as a World ' + |
24 | 'Heritage Site.</p>' + |
25 | '<p>Attribution: Uluru, <a href="http://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194">' + |
26 | 'http://en.wikipedia.org/w/index.php?title=Uluru</a> (last visited June 22, 2009).</p>' + |
27 | '</div>' + |
28 | '</div>' ; |
29 |
30 | var infowindow = new google.maps.InfoWindow({ |
31 | content: contentString |
32 | }); |
33 |
34 | var marker = new google.maps.Marker({ |
35 | position: myLatlng, |
36 | map: map, |
37 | title: "Uluru (Ayers Rock)" |
38 | }); |
39 |
40 | google.maps.event.addListener(marker, 'click' , function () { |
41 | infowindow.open(map,marker); |
42 | }); |
01 | <!DOCTYPE html> |
02 | < html > |
03 | < head > |
04 | < meta name = "viewport" content = "initial-scale=1.0, user-scalable=no" /> |
05 | < meta http-equiv = "content-type" content = "text/html; charset=UTF-8" /> |
06 | < title >Google Maps JavaScript API v3 Example: Info Window Simple</ title > |
07 | < link href = "http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel = "stylesheet" type = "text/css" /> |
08 | < script type = "text/javascript" src = "http://maps.google.com/maps/api/js?sensor=false" ></ script > |
09 | < script type = "text/javascript" > |
10 | function initialize() { |
11 | var myLatlng = new google.maps.LatLng(-25.363882,131.044922); |
12 | var myOptions = { |
13 | zoom: 4, |
14 | center: myLatlng, |
15 | mapTypeId: google.maps.MapTypeId.ROADMAP |
16 | } |
17 |
18 | var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); |
19 |
20 | var contentString = '< div id = "content" >'+ |
21 | '< div id = "siteNotice" >'+ |
22 | '</ div >'+ |
23 | '< h1 id = "firstHeading" class = "firstHeading" >Uluru</ h1 >'+ |
24 | '< div id = "bodyContent" >'+ |
25 | '< p >< b >Uluru</ b >, also referred to as < b >Ayers Rock</ b >, is a large ' + |
26 | 'sandstone rock formation in the southern part of the '+ |
27 | 'Northern Territory, central Australia. It lies 335 km (208 mi) '+ |
28 | 'south west of the nearest large town, Alice Springs; 450 km '+ |
29 | '(280 mi) by road. Kata Tjuta and Uluru are the two major '+ |
30 | 'features of the Uluru - Kata Tjuta National Park. Uluru is '+ |
31 | 'sacred to the Pitjantjatjara and Yankunytjatjara, the '+ |
32 | 'Aboriginal people of the area. It has many springs, waterholes, '+ |
33 | 'rock caves and ancient paintings. Uluru is listed as a World '+ |
34 | 'Heritage Site.</ p >'+ |
35 | '< p >Attribution: Uluru, < a href = "http://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194" >'+ |
36 | 'http://en.wikipedia.org/w/index.php?title=Uluru</ a > '+ |
37 | '(last visited June 22, 2009).</ p >'+ |
38 | '</ div >'+ |
39 | '</ div >'; |
40 | |
41 | var infowindow = new google.maps.InfoWindow({ |
42 | content: contentString |
43 | }); |
44 |
45 | var marker = new google.maps.Marker({ |
46 | position: myLatlng, |
47 | map: map, |
48 | title: 'Uluru (Ayers Rock)' |
49 | }); |
50 | google.maps.event.addListener(marker, 'click', function() { |
51 | infowindow.open(map,marker); |
52 | }); |
53 | } |
54 |
55 | </ script > |
56 | </ head > |
57 | < body onload = "initialize()" > |
58 | < div id = "map_canvas" ></ div > |
59 | </ body > |
60 | </ html > |
01 | <!DOCTYPE html> |
02 | < html > |
03 | < head > |
04 | < meta name = "viewport" content = "initial-scale=1.0, user-scalable=no" /> |
05 | < meta http-equiv = "content-type" content = "text/html; charset=UTF-8" /> |
06 | < title >Google Maps JavaScript API v3 Example: Info Window Simple</ title > |
07 | < link href = "http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel = "stylesheet" type = "text/css" /> |
08 | < script type = "text/javascript" src = "http://maps.google.com/maps/api/js?sensor=false" ></ script > |
09 | < script type = "text/javascript" > |
10 | function initialize() { |
11 | var myLatlng = new google.maps.LatLng(-25.363882,131.044922); |
12 | var myOptions = { |
13 | zoom: 4, |
14 | center: myLatlng, |
15 | mapTypeId: google.maps.MapTypeId.ROADMAP |
16 | } |
17 |
18 | var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); |
19 |
20 | var contentString = '< div id = "content" >'+ |
21 | '< div id = "siteNotice" >'+ |
22 | '</ div >'+ |
23 | '< h1 id = "firstHeading" class = "firstHeading" >Uluru</ h1 >'+ |
24 | '< div id = "bodyContent" >'+ |
25 | '< p >< b >Uluru</ b >, also referred to as < b >Ayers Rock</ b >, is a large ' + |
26 | 'sandstone rock formation in the southern part of the '+ |
27 | 'Northern Territory, central Australia. It lies 335 km (208 mi) '+ |
28 | 'south west of the nearest large town, Alice Springs; 450 km '+ |
29 | '(280 mi) by road. Kata Tjuta and Uluru are the two major '+ |
30 | 'features of the Uluru - Kata Tjuta National Park. Uluru is '+ |
31 | 'sacred to the Pitjantjatjara and Yankunytjatjara, the '+ |
32 | 'Aboriginal people of the area. It has many springs, waterholes, '+ |
33 | 'rock caves and ancient paintings. Uluru is listed as a World '+ |
34 | 'Heritage Site.</ p >'+ |
35 | '< p >Attribution: Uluru, < a href = "http://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194" >'+ |
36 | 'http://en.wikipedia.org/w/index.php?title=Uluru</ a > '+ |
37 | '(last visited June 22, 2009).</ p >'+ |
38 | '</ div >'+ |
39 | '</ div >'; |
40 | |
41 | var infowindow = new google.maps.InfoWindow({ |
42 | content: contentString, |
43 | maxWidth: 200 |
44 | }); |
45 |
46 | var marker = new google.maps.Marker({ |
47 | position: myLatlng, |
48 | map: map, |
49 | title: 'Uluru (Ayers Rock)' |
50 | }); |
51 | google.maps.event.addListener(marker, 'click', function() { |
52 | infowindow.open(map,marker); |
53 | }); |
54 | } |
55 |
56 | </ script > |
57 | </ head > |
58 | < body onload = "initialize()" > |
59 | < div id = "map_canvas" ></ div > |
60 | </ body > |
61 | </ html > |
联系客服