我有一個房子的簡單圖像(頂視圖,看起來像一個3D模型),我想把這張房子的照片放在這個房子所在的地方(在路線圖上)。 This is an example of what I want。但是我有一個很大的位置問題,我無法正確放置圖像,它被撕裂或開走(an example of what I got)。 我讀過關於疊加層的所有文檔,但我不知道如何製作這個東西,也許有人告訴我如何去做或者顯示出去的方向?代碼如何使用Api v3在Google Map上放置圖像?
例子:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Ground Overlays</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
var Overlay;
function initialize() {
var house = new google.maps.LatLng(55.734907, 37.571526);
var imageBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(55.734603,37.571374),
new google.maps.LatLng(55.734944,37.572097),
new google.maps.LatLng(55.735032,37.571221),
new google.maps.LatLng(55.735201,37.570343),
new google.maps.LatLng(55.735218,37.570840),
new google.maps.LatLng(55.735238,37.571670),
new google.maps.LatLng(55.735423,37.571147),
new google.maps.LatLng(55.735551,37.570891)
);
var mapOptions = {
zoom: 17,
center: house,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
Overlay = new google.maps.GroundOverlay(
'file:///home/map_top.png',
imageBounds);
Overlay.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>
問題可能是你的界限。只使用矩形的SouthWest和NorthEst角的兩個點。 'LatLngBounds(sw?:LatLng,ne?:LatLng)' 嘗試改變其中一個點(sw),直到您到達正確的位置。 – sabotero
好的,謝謝你的回答,但有什麼不同的方法來達到我想要的?可能是這些讓這種有趣的東西(第一個例子)使用另一種方法的人? – user2596615
您可以上傳圖片_map_top.png_來嘗試一下 – sabotero