我尝试通过 setCenter 方法设置地图中心,但仍然无法正常工作。地图不动。我尝试使用从投影到地图投影的转换但没有成功。这是代码的一部分。谢谢。
<script type="text/javascript">
var lon = 15.869378; //WGS LL84
var lat = 49.528964;
var zoom = 5;
var map, layer;
function init(){
map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.TMS("Name",
"[URL]",
{ 'type':'png', 'getURL':get_my_url });
map.addLayer(layer);
var markers = new OpenLayers.Layer.Markers( "Markers" );
map.addLayer(markers);
markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(lon, lat).transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject())));
map.setCenter(new OpenLayers.LonLat(lon, lat).transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()), zoom);
}
</script>