我想在雷達的幫助下,在時間上改變其位置來實現雲層覆蓋圖像中的循環特徵。這是如何實施的。我正在使用谷歌地圖v3。覆蓋谷歌地圖v3的循環功能
0
A
回答
2
以下是覆蓋圖的一個例子,及時移動。作爲一個例子,我讓吃豆人在比利時追逐幽靈。
編輯:我添加了一個啓動和停止按鈕
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Moving overlays</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
#directions-panel {
height: 100%;
float: right;
width: 390px;
overflow: auto;
}
#map-canvas {
margin-right: 400px;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<script>
var data = [
{time: '20:00:00', pacman:{lat: 48.8, lng: 4.3}, ghost:{lat: 50.0, lng: 4.0}},
{time: '20:30:00', pacman:{lat: 49.4, lng: 4.4}, ghost:{lat: 50.2, lng: 4.2}},
{time: '21:00:00', pacman:{lat: 50.0, lng: 4.5}, ghost:{lat: 50.4, lng: 4.4}},
{time: '21:30:00', pacman:{lat: 50.6, lng: 4.6}, ghost:{lat: 50.6, lng: 4.6}}
];
var dataCounter = 0;
var dataInterval = 1000; // every new frame every 1000ms. Feel free to change this
var pacman = null;
var ghost = null;
var map;
var timer;
function initialize() {
directionsDisplay = new google.maps.DirectionsRenderer();
var mapOptions = {
zoom: 7,
center: new google.maps.LatLng(50.5, 4.5) // Belgium
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions
);
}
function ghostIcon() {
return {
size: new google.maps.Size(20, 20),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(10, 10),
url: 'http://1.bp.blogspot.com/_ZEF1cuisJEs/SGsuTtZd5cI/AAAAAAAAANY/iAqmMPQaX7g/s400/red.png'
};
}
function pacmanIcon() {
return {
size: new google.maps.Size(20, 20),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(10, 10),
url: 'http://www.scientix.eu/scientix-2-theme/images/emoticons/pac_man.gif'
};
}
// this function will be called every 1000ms (or what ever dataInterval is).
function timelapse() {
var item = data[dataCounter % data.length]; // easiest way to make a loop. After the last item, item 0 starts again
if (! ghost) {// if the marker doesn't exist yet, first create it.
ghost = new google.maps.Marker({
position: new google.maps.LatLng(item.ghost.lat, item.ghost.lng),
icon: ghostIcon(),
map: map
});
}
else {
ghost.setPosition(new google.maps.LatLng(item.ghost.lat, item.ghost.lng))
}
if (! pacman) {// if the marker doesn't exist yet, first create it.
pacman = new google.maps.Marker({
position: new google.maps.LatLng(item.pacman.lat, item.pacman.lng),
icon: pacmanIcon(),
map: map
});
}
else {
pacman.setPosition(new google.maps.LatLng(item.pacman.lat, item.pacman.lng))
}
dataCounter++;
timer = setTimeout(timelapse, dataInterval);
}
function start_timelapse() {
clearTimeout(timer); // if you don't add this, the previous timer is still working, you'll get two parallel timeOuts
timelapse();
}
function stop_timelapse() {
clearTimeout(timer); // prevents setTimeout(timelapse, dataInterval); from continuing
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<input type="button" id="start" value="Start" onclick="start_timelapse()">
<input type="button" id="stop" value="Stop" onclick="stop_timelapse()">
<div id="map-canvas"></div>
</body>
</html>
相關問題
- 1. 圈覆蓋谷歌地圖API V3 JS
- 2. Javascript谷歌地圖V3 - 爲什麼這不清除覆蓋功能的工作?
- 3. 谷歌地圖與覆蓋
- 4. 谷歌地圖覆蓋
- 5. 谷歌地圖覆蓋
- 6. 谷歌地圖覆蓋層
- 7. 谷歌地圖v3 - 覆蓋默認的平滑行爲
- 8. 谷歌地圖V3地理編碼和循環中的標記
- 9. 谷歌地圖javascript api v3 - 覆蓋在道路後面
- 10. 谷歌地圖API v3圈覆蓋問題
- 11. 谷歌地圖V3刪除折線覆蓋
- 12. 自定義風格到谷歌地圖V3覆蓋
- 13. 如何使定製覆蓋拖動使用谷歌,地圖V3
- 14. 如何把谷歌地圖v3的fancybox谷歌地圖v3
- 15. 谷歌地圖:更新圖片覆蓋
- 16. 谷歌地圖透明圖像覆蓋
- 17. 預加載谷歌地圖覆蓋圖
- 18. 谷歌地圖視圖教程 - 覆蓋
- 19. 谷歌地圖簡單圖案覆蓋
- 20. 如何覆蓋谷歌地圖的onresume
- 21. 可縮放的谷歌地圖覆蓋
- 22. 谷歌地圖的天氣覆蓋
- 23. 谷歌地圖 - 覆蓋樣式
- 24. 谷歌地圖得到覆蓋誤差
- 25. 表面覆蓋谷歌地圖
- 26. 谷歌地圖與覆蓋到pdf
- 27. 谷歌地圖API:覆蓋區域
- 28. 谷歌地圖:平鋪覆蓋
- 29. 谷歌地圖覆蓋更新技術
- 30. Popoup on tap谷歌地圖覆蓋
做那些雲的形狀改變而動?你從哪裏得到那些雲的數據?可以製作覆蓋圖(及時);沒問題。 – 2014-10-20 12:41:51