首页 > 代码库 > google地图API的简单使用

google地图API的简单使用

<div id="contact_container" style="width:700px;height:600px;"></div>
<script type="text/javascript">
function initialize() {
   var myLatlng = new google.maps.LatLng(39.95745,116.32764);
   var myOptions = {
     zoom: 18,
     center: myLatlng,
     mapTypeId: google.maps.MapTypeId.ROADMAP
   }
   var map = new google.maps.Map(document.getElementById("contact_container"), myOptions);
   var marker = new google.maps.Marker({
      position: map.getCenter(),
      map: map,
      title: ‘CAAS‘
    });
 }
   
 function loadScript() {
   var script = document.createElement("script");
   script.type = "text/javascript";
   script.src = http://www.mamicode.com/"
http://maps.google.com/maps/api/js?language=en&sensor=false&callback=initialize";
   document.body.appendChild(script);
 }
   
 window.onload = loadScript;
</script>

google地图API的简单使用