在地图上添加一个简单的标记

时间:2013-06-14 16:00:09

标签: javascript function google-maps google-maps-markers

我在地图上添加简单标记有很大问题

我使用此功能

但是当我想添加标记时,我的网络已经死了

function MapLoad() {
  var Lat = 43.485505;
  var Lng = 16.261093;

  var mapOptions = {
    center: new google.maps.LatLng(Lat, Lng),
    zoom: 17,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var map = new google.maps.Map(document.getElementById("map"),
        mapOptions);
}

1 个答案:

答案 0 :(得分:0)

https://developers.google.com/maps/documentation/javascript/examples/marker-simple?hl=pt-br

中的Google文档示例
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Simple markers</title>
    <script src="http://maps.google.com/maps/api/js?v=3&sensor=false"></script>
    <script>
    function initialize() {
      var myLatlng = new google.maps.LatLng(43.485505,16.261093);
      var mapOptions = {
        zoom: 4,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      }  
      var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
      var marker = new google.maps.Marker({
          position: myLatlng,
          map: map,
          title: 'Hello World!'
      });
    }

    google.maps.event.addDomListener(window, 'load', initialize);
    </script>
  </head>
  <body>
    <div id="map-canvas" style="width: 500px; height: 500px;"></div>
  </body>
</html>