Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps 在地图上显示区域_Google Maps_Google Maps Api 3 - Fatal编程技术网

Google maps 在地图上显示区域

Google maps 在地图上显示区域,google-maps,google-maps-api-3,Google Maps,Google Maps Api 3,我想在我的地图上显示这个地区,就像我们在这张地图上看到的新泽西州东南部一样: 找了两天,我还没找到怎么做。我刚刚找到了我要显示的区域的id,它是0x478e39c0d43a1b77:0x8A06A97EAE31010,代表了,但我不知道它是否真的对我有用 我如何在下面的代码中对其进行整型 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1

我想在我的地图上显示这个地区,就像我们在这张地图上看到的新泽西州东南部一样:

找了两天,我还没找到怎么做。我刚刚找到了我要显示的区域的id,它是0x478e39c0d43a1b77:0x8A06A97EAE31010,代表了,但我不知道它是否真的对我有用

我如何在下面的代码中对其进行整型

<!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>

非常感谢

查看地图多边形的参考资料

https://developers.google.com/maps/documentation/javascript/referencePolygonOptions

您需要将所有这些点推送到一个数组中,并将该数组提供给多边形


可以复制的好,非常感谢。我已经想过这个解决方案,但是。。。首先,我如何获得这些点,因为我只有id而没有形状的坐标。第二,由于谷歌地图已经显示了这些地区,我认为已经有一个工具可以做到这一点,它会看到更好的。这个问题我至少见过两次。我不会手工编辑边界。我手头没有链接,但是有美国各地的KML数据库。1你必须搜索你所在地区的一些KML数据集。2我没有看到任何直接从谷歌获取这些数据的工具。谢谢你的回答。我将尝试查找我所在地区的kml数据,也许有一次我会找到google如何准确显示其地区。对不起,在网上旅行两天后,我没有找到任何关于我所在地区限制的kml。。