-1

私が作成しているカスタム Google マップの座標 (38.0、-98.0) にマーカーを追加し、座標 (45.0、-100.0) に別のマーカーを追加するにはどうすればよいでしょうか? これまでのところ、これは私が持っているコードです:

<script type="text/javascript">

  var map;
  var grayStyles = [
    {
      featureType: "all",
      stylers: [
        { saturation: -100 },
      ]
    },
  ];
  var mapOptions = {
    center: new google.maps.LatLng(38, -98),
    zoom: 5,
    styles: grayStyles,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };

  function initialize() {
    map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
  }

</script>
4

2 に答える 2

2

シンプルなマーカー:

var marker1 = new google.maps.Marker({
      position: new google.maps.LatLng(38.0, -98.0),
      map: map,
  });

var marker2 = new google.maps.Marker({
      position: new google.maps.LatLng(45.0, -100.0),
      map: map,
  });
于 2013-02-21T01:01:47.723 に答える
0

これは私が使用したコードで、行の後に配置されます

map = new google.maps.Map(documen......

そして、このコードを何度も繰り返して、より多くのマーカーを取得できます

  var ncenter = new google.maps.LatLng(parseFloat('52.43598') , parseFloat('16.94412'));  /* this is the position */ 
  var image = {
    url: '/img/xspot.png',
    // This marker is 20 pixels wide by 32 pixels tall.
    size: new google.maps.Size(115, 86),
    // The origin for this image is 0,0.
    origin: new google.maps.Point(0,0),
    // The anchor for this image is the base of the flagpole at 0,32.
    anchor: new google.maps.Point(57, 71)
  }; /* You can ignore the image mark */ 
  var beachMarker = new google.maps.Marker({
      position: ncenter,
      map: map,
      icon: image // if you ignore image related code above, also remove this line
  });
于 2013-02-21T00:57:16.870 に答える