0
我有一個網站的背景是由谷歌地圖組成的這個想法。 當用戶滾動地圖時必須「移動」/平移到特定位置。 我發現了一個腳本,將谷歌地圖設置爲我的背景,所以這不是問題。如何在滾動位置上平移谷歌地圖
現在我的問題是:如何根據滾動位置使地圖「移動」/平移?
任何幫助是極大的讚賞:)
我有一個網站的背景是由谷歌地圖組成的這個想法。 當用戶滾動地圖時必須「移動」/平移到特定位置。 我發現了一個腳本,將谷歌地圖設置爲我的背景,所以這不是問題。如何在滾動位置上平移谷歌地圖
現在我的問題是:如何根據滾動位置使地圖「移動」/平移?
任何幫助是極大的讚賞:)
使用API(https://developers.google.com/maps/documentation/javascript/reference#Map)的.panTo
方法,並從滾動事件
像
$(document).on('scroll', function(){
// get current scroll position
var currentScroll = $('element that scrolls').scrollTop();
// calculate a new map point based on the currentScroll value
var latLng = new google.maps.LatLng(somelat, somelong);
// pan to it
map.panTo(latLng); // assuming map refers to the map object
});
謝謝!我要玩這個:) – 2013-04-21 15:37:29
動畫調用或地方上的鏈接用戶正在瀏覽您的網站? – Lobato 2013-04-21 15:05:55