OpenLayers 显示全球 720 度

发布于 2024-12-05 08:07:36 字数 636 浏览 6 评论 0原文

我当前的 OpenLayers 如下所示: 错误的地图 http://i1179.photobucket.com/albums/x384/yoyomyo /Picture2.png

它的大陆数量是应有数量的两倍。

我试图为我的地图设置边界,但整个地图拒绝渲染:

var map = new OpenLayers.Map('map', {restrictedExtent: new OpenLayers.Bounds(-180, -90, 180, 90)});

var layer = new OpenLayers.Layer.OSM( "Simple OSM Map");

map.addLayers([layer]);

map.setCenter(
    new OpenLayers.LonLat(-71.147, -42.472).transform( new OpenLayers.Projection("EPSG:4326"),map.getProjectionObject()), 
    12);

有地图大师知道我做错了什么吗?

My current OpenLayers looks like the following:
a wrong map http://i1179.photobucket.com/albums/x384/yoyomyo/Picture2.png

It has twice as many continents as there should be.

I was trying to set Bounds to my map, but the entire map just refuses to render:

var map = new OpenLayers.Map('map', {restrictedExtent: new OpenLayers.Bounds(-180, -90, 180, 90)});

var layer = new OpenLayers.Layer.OSM( "Simple OSM Map");

map.addLayers([layer]);

map.setCenter(
    new OpenLayers.LonLat(-71.147, -42.472).transform( new OpenLayers.Projection("EPSG:4326"),map.getProjectionObject()), 
    12);

Does any Map guru know what I did wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

草莓酥 2024-12-12 08:07:36

WrapDateLine

尝试 wrapDateLine:false

WrapDateLine

Try wrapDateLine:false

梦过后 2024-12-12 08:07:36

听起来你想设置 maxExtent。

http://trac.osgeo.org/openlayers/wiki/SettingZoomLevels

否则我没有线索。 :)

It sounds like you want to set maxExtent.

http://trac.osgeo.org/openlayers/wiki/SettingZoomLevels

Otherwise I have no clue. :)

乖乖兔^ω^ 2024-12-12 08:07:36

用一个例子来回答会更容易。我放大12是相当遥远的。是的,您可以放大 OSM http://www.openstreetmap.org/

在该网站中,他们使用这些值

    var centre = new OpenLayers.LonLat(-0.1, 51.5);
    var zoom = 5;

    setMapCenter(centre, zoom); //It calls map.setCenter()

It would be easier to answer with an example to work off of. I would zoom in 12 is pretty far out. And yes you can zoom in on OSM http://www.openstreetmap.org/

In that site, they use these values

    var centre = new OpenLayers.LonLat(-0.1, 51.5);
    var zoom = 5;

    setMapCenter(centre, zoom); //It calls map.setCenter()
南渊 2024-12-12 08:07:36

好吧我放弃了。我认为这就是 OpenStreetMap 显示地图的方式。
我看过很多demo,都是和上面的一样。

Okay I give up. I think this is just the way OpenStreetMap displays its map.
I have seen many demos and they are all like the one above.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文