我想在我的地图上显示与我们在这个地区完全相同的地区: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天后,我还没有找到怎么做。我刚刚找到了我想要显示的区域的ID,即0x478e39c0d43a1b77:0x8a06a97eae310a0(代表canton of Bern in Switzerland,但我不知道它是否真的对我有帮助。)
如何在我的实际代码中整数呢?
<!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>
非常感谢
答案 0 :(得分:0)
查看地图Polygon的参考。
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