<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API v3 Example: KmlLayer GeoRSS</title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3.7&sensor=false&language=zh-CN"></script>
<script type="text/javascript">
function initialize() {
var myLatlng = new google.maps.LatLng(31.283245,121.469925);
var myOptions = {
zoom: 9,
center: myLatlng,
backgroundColor: 'F8F8FF',
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
//show traffic
var trafficLayer = new google.maps.TrafficLayer();
trafficLayer.setMap(map);
//To add icon
var marker = new google.maps.Marker({
position: myLatlng,
icon: "http://map.amap.com/images/layer_icon_1040.png",
title:"Hello World!"
});
// To add the marker to the map, call setMap();
marker.setMap(map);
var contentString = '<div id="content">'+
'<a href="http://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194">'+
'http://en.wikipedia.org/w/index.php?title=Uluru</a> '+
'</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString,
maxWidth: 200
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas"></div>
</body>
</html>