Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要知道如何使用 javascript 重新定位和缩放 Openlayer 地图?例如,我有一个包含城市的下拉菜单,当我选择其中一个城市时,中心和缩放将更改为当前城市,依此类推。
是的,你可以这么做。你只需要传递那个城市的latandlon并传递给这个函数,它就会把它放在center.
lat
lon
center
function setCenter(lat,lon) { var lonlat = new OpenLayers.LonLat(lon, lat); map.panTo(lonlat); }
对象在哪里map:
map
map = new OpenLayers.Map('map', {numZoomLevels: 2});
的所有示例都openlayermap存在于此处:
openlayermap
http://openlayers.org/dev/examples/