0

我想在我的地图上显示该地区,就像我们可以在这个上看到新泽西州一样:http ://maps.google.com/maps?q=New+Jersey,+%C3%89tats-Unis&hl= fr&ie=UTF8&sll=46.957442,7.447329&sspn=0.010823,0.019205&oq=new+je&hnear=New+Jersey&t=m&z=8

找了2天,还没找到怎么做。我刚刚找到要显示的 Region 的 id,即 0x478e39c0d43a1b77:0x8a06a97eae310a0 (代表瑞士的伯尔尼州,但我不知道它是否对我真的有用)。

如何在我的实际以下代码中对其进行整数运算?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
  html { height: 100% }
  body { height: 100%; margin: 0px; padding: 0px }
  #map_canvas { height: 100%; width: 100% }
    </style>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
</head>
<title>MA's Karte</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">// charge les scripts Google</script>
<script type="text/javascript">

  var markers = []; // tableau de marqueurs
  var iterator = 0; // compteur de marqueurs
  var map;

  // Liste des adresses géocodées
  var pers = new Array();
  var coord = new Array();
  <?php
    // Connection à la base de données
  include 'connexion.php';

  $ktd = mysql_query('SELECT name, vorname, coorX, coorY FROM ma WHERE  grup != 14 ORDER BY coorY');
        $num_tab = 0;
      while($ligne = mysql_fetch_array($ktd)) {
        echo 'coord['.$num_tab.'] = new google.maps.LatLng('.$ligne['coorX'].', '.$ligne['coorY'].');';
    echo 'pers['.$num_tab.'] = "'.$ligne['vorname'].' '.$ligne['name'].'";';
    $num_tab++;
  }
  ?>

  // Affichage de la carte
  function initialize() {
    var mapOptions = {
      zoom: 9,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      center: new google.maps.LatLng(46.801,7.148666) // Coordonnées de Fribourg pour centrer la carte
    };
    map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
  }

  // Ajout des marqueurs en chute
  function drop() {
    for (var i = 0; i < coord.length; i++) {
      setTimeout(function() {
        addMarker();                
      }, i * 100);
    }
  }

    var onMarkerClick = function() {
      var marker = this;
      var latLng = marker.getPosition();
      infoWindow.setContent('<h3>Marker position is:</h3>' +
      latLng.lat() + ', ' + latLng.lng());

      infoWindow.open(map, marker);
    };

  // Création des marqueurs
  function addMarker() {
   // document.getElementById("test").innerHTML = coord[iterator];
      markers.push(new google.maps.Marker({
      position: coord[iterator],
      map: map,
      draggable: false,
      animation: google.maps.Animation.DROP,
      title: pers[iterator]
    }));

    iterator++;
  }
</script>
</head>
<body onload="initialize(); drop();">
<div id="map_canvas">map div</div>
</body>
</html>

非常感谢

4

1 回答 1

0

查看地图多边形的参考。

https://developers.google.com/maps/documentation/javascript/reference#Polygon https://developers.google.com/maps/documentation/javascript/reference#PolygonOptions

您需要将所有这些点推入一个数组并将该数组提供给多边形。

https://developers.google.com/maps/documentation/javascript/overlays#PolygonOptions

于 2012-04-05T14:58:10.803 回答