使用带有局部底图的openlayers? [英] Using openlayers with a local basemap?

查看:92
本文介绍了使用带有局部底图的openlayers?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

"OpenLayers库提供了JavaScript API,可轻松将来自各种来源的地图合并到您的网页或应用程序中."但是,通过扫描文档,各种来源似乎仅包括基于Web的地球地图提供商.

"The OpenLayers library provides a JavaScript API which makes it easy to incorporate maps from a variety of sources into your webpage or application." However, from scanning the documentation the variety of sources appears to include only web-based providers of maps of the Earth.

是否可以使用OpenLayers在本地存储的底图之上显示要素,例如海图(例如

Is it possible to use OpenLayers to display features on top of locally-stored basemaps such as marine charts (e.g., http://www.charts.noaa.gov/InteractiveCatalog/nrnc.shtml?rnc=12280) or arbitrary (non-Earth) raster images with artificial cartesian coordinates?

-编辑-

以下页面显示了本地存储的图像,与

The following page displays a locally-stored image, contrary to the documentation which says that the image must be web-accessible. But instead of a single file, is there a way to use multiple image files as tiles?

<html>
  <head>
    <title>OpenLayers Example</title>
    <script src="http://openlayers.org/api/OpenLayers.js"></script>
  </head>
  <body>
    <div style="width:640px; height:480px; border:3px solid" id="map"></div>
    <script defer="defer" type="text/javascript">
        var options = {
            maxResolution: 10,
            units: 'm',
            resolutions: [10, 5, 2, 1, .5],
        };
        var map = new OpenLayers.Map('map', options);
        var extent = new OpenLayers.Bounds(-4824, -3294, 4824, 3294);
        var size = new OpenLayers.Size(4824, 3294);
        var img = new OpenLayers.Layer.Image( "Basemap",
        "maps/map0.jpg", extent, size, {layers: 'basic'} );
        map.addLayer(img);
        map.zoomToMaxExtent();
    </script>
  </body>
</html>

推荐答案

有一个示例此处在本地使用OpenStreetMap切片,而无需直接使用http.显然,您需要将自己的图块以XYZ格式放置才能起作用.这是OSM层的.每个图块的xyz均来自 OpenLayers.Layer.XYZ ,当然,它是为简化和全局覆盖而设计的.但是,您可以使用自己的坐标系轻松创建自己的图层,以类似的方式工作.

There is an example here of using OpenStreetMap tiles locally, without using http directly. Obviously, you would need to put your tiles in XYZ format for this to work. Here is the source for the OSM layer. The xyz of each tile is derived from OpenLayers.Layer.XYZ, which, of course, is designed for simplicity and global coverage. However, you could easily create your own layer with your own coordinate system to work in a similar fashion.

从加载的角度来看,相关的行是:

The relevant line from a loading point of view is:

 var newLayer = new OpenLayers.Layer.OSM("Local Tiles", 
                   "tiles/${z}/${x}/${y}.png",
                   {numZoomLevels: 19, 
                    alpha: true, 
                    isBaseLayer: false}
);   

注意:通常,我发现示例和源代码比文档是更好的信息源.我这么说是不带批评的,像大多数开源项目一样,OpenLayers的开发人员资源有限,所以仅仅因为没有文件记载,并不意味着就无法完成.

Note: I have found, generally, that the examples and source code are a better source of information than the documentation. I say this without criticism, OpenLayers has limited developer resources, like most open source projects, so just because there is nothing documented, doesn't mean it can't be done.

这篇关于使用带有局部底图的openlayers?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆