我只是想向平移使用我的地圖座標:panTo()持續時間不工作?
earth.panTo([0,0], {animate: true, duration: 2.0});
但持續時間選項被忽略 - 它似乎默認的持續時間爲10秒,不能更改。
對於它的價值,我使用WRLD的(eegeo)3D地球插件建立在單張的頂部,而我通過訪問它:
<script src="https://cdn-webgl.wrld3d.com/wrldjs/dist/latest/wrld.js"></script>
這裏是我的html文件:
<!DOCTYPE HTML>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="https://cdn-webgl.wrld3d.com/wrldjs/dist/latest/wrld.js"></script>
<title></title>
</head>
<body onload="App.createGlobe()">
<div id="earth_div"></div>
<script src="js/app.js"></script>
</body>
</html>
這裏是我的app.js文件:
App = {
createGlobe: function() {
var options = {zoom: 3, center: [40.3461, -94.8725]};
var earth = new L.Wrld.map('earth_div', "insert_api_key_here", options);
customMarker = L.Marker.extend({
options: {
markerID : ''
}
});
$.getJSON('../causes.json', function(data) {
for (i = 0; i < data.length; i ++) {
var newMarkerOptions = {riseOnHover: true, markerID: data[i].id};
var newMarker = new customMarker([], newMarkerOptions);
newMarker.setLatLng(data[i].mapCoord);
newMarker.addTo(earth);
markerClicked(newMarker);
}
function markerClicked(marker) {
marker.on('click', function() {
earth.panTo(data[marker.options.markerID].mapCoord, {animate: true, duration: 2.0});
});
};
});
}
};
你能提供一個你的代碼的最小例子嗎?也許在[blockbuilder](http://blockbuilder.org/)可以爲你工作? – Camilo
@Camilo當然,編輯更清晰 – jeff