免费视频|新人指南|投诉删帖|广告合作|地信网APP下载

查看: 2608|回复: 5
收起左侧

[技术交流] 如何将谷歌地图在基于OpenLayers的服务器端进行部署的方法

[复制链接]

31

主题

463

铜板

6

好友

助理工程师

Rank: 5Rank: 5

积分
393
QQ
发表于 2013-10-11 13:26 | 显示全部楼层 |阅读模式
如何将谷歌地图在基于OpenLayers的服务器端进行部署的方法
一、准备工作
1、到OpenLayers的官方网站下载压缩包,如下图所示。

img1.jpg (37.71 KB, 下载次数: 0)
下载附件 保存到相册
2013-10-11 11:47 上传




2、到水经注软件官方网站下载《水经注万能地图下载器》和《水经注影像转换器》。
二、下载示例数据
这里以《水经注万能地图下载器》为你说明如何下载谷歌卫星地图。
安装万能地图下载器以后,软件启动时会显示选择在线地图的对话框,请选择“卫星.谷歌”即会显示在线的谷歌卫星地图窗口,如下图所示。

img2.jpg (46.98 KB, 下载次数: 0)
下载附件 保存到相册
2013-10-11 11:47 上传




由于只是为了作演示说明如何将谷歌地图在基于在OpenLayers的服务器端进行部署的方法,这里我们只需要框选中国范围,即点击工具栏上的“框选下载区域”,然后在视图中绘制选择范围,如下图所示。

img3.jpg (66.5 KB, 下载次数: 0)
下载附件 保存到相册
2013-10-11 11:47 上传




在范围中双击鼠标左键,显示新建任务对话框,在该对话框中我们只选择1到7级进行下载即可,如下图所示。

img4.png (20.2 KB, 下载次数: 0)
下载附件 保存到相册
2013-10-11 11:47 上传




下载完成后,关闭万能地图下载器。
三、生成ArcGIS Server切片
启动《水经注影像转换器》,如下图所示。

img5.png (16.01 KB, 下载次数: 0)
下载附件 保存到相册
2013-10-11 11:47 上传




点击“输入地图文件”区对应的“打开”文件按钮,如下图所示。

img6.png (16.06 KB, 下载次数: 0)
下载附件 保存到相册
2013-10-11 11:47 上传




在显示的“输入地图文件”对话框中,点击“+”按钮导入《水经注万能下载器》下载的“中国.dat”文件,如下图所示。

img7.png (7.84 KB, 下载次数: 0)
下载附件 保存到相册
2013-10-11 11:47 上传




点击“确定”按钮,导入文件。
在“输出地图文件”区中点击“属性”参数设置按钮,如下图所示。

img8.png (16.74 KB, 下载次数: 0)
下载附件 保存到相册
2013-10-11 11:47 上传




在显示的“输出栅格地图文件”中选择导出类型为“瓦片:ArcGIS Server”,保存类型为“JPG(*.jpg)”,如下图所示。

img9.png (10.51 KB, 下载次数: 0)
下载附件 保存到相册
2013-10-11 11:47 上传




点击“确定”按钮,完成设置。
点击“转换”按钮,开始生成WGS84坐标系的ArcGIS Server切片,如下图所示。

img10.png (21.78 KB, 下载次数: 0)
下载附件 保存到相册
2013-10-11 11:47 上传




生成后的结果,如下图所示。

img11.png (41.54 KB, 下载次数: 0)
下载附件 保存到相册
2013-10-11 11:47 上传




四、服务器端地图引擎配置
第一步:将下载的OpenLayers-2.13.1.zip解压到D盘Test目录。
第二步:将下载结果“中国_Esri瓦片”目录重命名为“data”,如下图所示。

img12.png (40.3 KB, 下载次数: 0)
下载附件 保存到相册
2013-10-11 11:48 上传




第三步:新建网站在IIS中新建网站,如下图所示。

img13.jpg (48.02 KB, 下载次数: 0)
下载附件 保存到相册
2013-10-11 11:48 上传




这里我们将网站命名为“TEST”,物理路径设置为“D:\Test”,端口设置为“8080”,如下图所示。

img14.png (29 KB, 下载次数: 0)
下载附件 保存到相册
2013-10-11 11:48 上传




第四步:将以下代码复制并保存为html文件(如“Example_ArcGIS Server.html”),放到“D:\Test\OpenLayers-2.13.1\examples”目录中。
==============================代码开始=============================
< !DOCTYPE html>
< html>
< head>
    <title>ArcGIS Server Map Cache Example (Direct Access)</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link rel="stylesheet" href="OpenLayers-2.13.1/theme/default/style.css" type="text/css">
    <link rel="stylesheet" href="style.css" type="text/css">
    <script src="../lib/OpenLayers.js"></script>
    <script src="../lib/OpenLayers/Layer/ArcGISCache.js" type="text/javascript"></script>
    <script type="text/javascript">
        /* First 4 variables extracted from conf.xml file */

        /* Tile layers & map MUST have same projection */
        var proj = 'EPSG:4326';


        /* Layer can also accept serverResolutions array
        * to deal with situation in which layer resolution array & map resolution
        * array are out of sync*/
        var mapResolutions = [
                              1.09978378260965, 0.549891891304825, 0.274945945652412,

0.137472972826206, 0.068736486413103, 0.0343682432065515, 0.0171841216032758,
                              0.0085920608016379, 0.0042960304008189, 0.0021480152004095,

0.0010740076002047,5.370038001023672e-4, 2.685019000511836e-4, 1.342509500255918e-4,
                              6.71254750127959e-5, 3.356273750639795e-5, 1.678136875319897e-5,

8.390684376599487e-6, 4.195342188299744e-6, 2.097671094149872e-6,

1.048835547074936e-6
                             ];

        /* For this example this next line is not really needed, 256x256 is default.
        * However, you would need to change this if your layer had different tile sizes */
        var tileSize = new OpenLayers.Size(256, 256);

        /* Tile Origin is required unless it is the same as the implicit map origin
        * which can be affected by several variables including maxExtent for map or base layer

*/
        var agsTileOrigin = new OpenLayers.LonLat(-180, 85.0511287798065);

        /* This can really be any valid bounds that the map would reasonably be within */
        /*  var mapExtent = new OpenLayers.Bounds

(293449.454286,4307691.661132,314827.830376,4323381.484178); */
        var mapExtent = new OpenLayers.Bounds(-180, -85.0511287798065, 180,

85.0511287798065);

        var aerialsUrl = 'http://localhost:8080/data/_alllayers';

        var map;
        function init() {
            map = new OpenLayers.Map('map', {
                maxExtent: mapExtent,
                controls: [
                        new OpenLayers.Control.Navigation(),
                        new OpenLayers.Control.LayerSwitcher(),
                        new OpenLayers.Control.PanZoomBar(),
                        new OpenLayers.Control.MousePosition()]
            });

            var baseLayer = new OpenLayers.Layer.ArcGISCache('Aerials', aerialsUrl, {
                tileOrigin: agsTileOrigin,
                resolutions: mapResolutions,
                sphericalMercator: false,
                maxExtent: mapExtent,
                useArcGISServer: false,
                isBaseLayer: true,
                type: 'jpg',
//                projection: proj
            });
            map.addLayers([baseLayer]);

            //map.zoomToExtent(new OpenLayers.Bounds(295892.34, 4308521.69, 312825.71,

4316988.37));
            map.setCenter(new OpenLayers.LonLat(104.08, 30.645).transform

(map.displayProjection, map.getProjectionObject()), 3);
        }
    </script>
< /head>
< body>
    <h1 id="title">
        ArcGIS Server Map Cache Example (Direct Access)</h1>
    <div id="tags">
    </div>
    <p id="shortdesc">
        Demonstrates the basic initialization of the ArcGIS Cache layer using a prebuilt
        configuration, and direct tile access from a file store.
    </p>
    <div id="map" class="smallmap">
    </div>
    <div id="docs">
        <p>
            This example demonstrates using the ArcGISCache layer for accessing ESRI's ArcGIS
            Server (AGS) Map Cache tiles directly via the folder structure and HTTP. Toggle
            the visibility of the AGS layer to demonstrate how the two maps are lined up

correctly.</p>
        <h2>
            Notes on this Layer</h2>
        <p>
            It's important that you set the correct values in your layer, and these values will
            differ between tile sets. You can find these values for your layer in conf.xml at
            the root of your cache. (ie. <a

>
                http://serverx.esri.com/arcgisca ... /conf.xml</a>)</p>
        <p>
            For fused map caches this is often

http:<i>ServerName</i>/arcgiscache/<i>MapServiceName</i>/Layers
            <br>
            For individual layer caches this is often

http:<i>ServerName</i>/arcgiscache/<i>LayerName</i>/Layers
        </p>
        <h2>
            Other Examples
        </h2>
        <p>
            This is one of three examples for this layer. You can also configure this layer
            to use <a href="arcgiscache_ags.html">prebuilt tiles from a live server.</a> It
            is also possible to let this <a href="arcgiscache_jsonp.html">layer 'auto-configure'
                itself using the capabilities json object from the server itself when using a live
                ArcGIS server.</a>
        </p>
    </div>
< /body>
< /html>
==============================代码结束=============================
第五步:双击打开刚才保存的文件,如果部署正确,则将会显示离线WGS84卫星地图的浏览结果,如下图所示。

img15.jpg (66.08 KB, 下载次数: 0)
下载附件 保存到相册
2013-10-11 11:48 上传




当然,你也可以通过以下网址进行访问,效果也是一样的。
http://localhost:8080/OpenLayers-2.13.1/examples/Example_ArcGIS%20Server.html
以上即是如何将谷歌地图进行WGS84坐标系的ArcGIS Server切片后,并基于OpenLayers在服务器端进行部署的全部过程及示例源码,你可以基于此平台并根据自己的实际需求作进一步开发了。

4

主题

1万

铜板

56

好友

地信学员

Rank: 12Rank: 12Rank: 12

积分
11412

灌水勋章宣传勋章贡献勋章

发表于 2013-10-17 19:49 | 显示全部楼层
来看看,感谢楼主分享

评分

参与人数 1铜板 +1 收起 理由
admin + 1 亲,你好快哦~~~

查看全部评分

回复 支持 反对

使用道具 举报

26

主题

6万

铜板

22

好友

传奇会员

Rank: 30Rank: 30Rank: 30Rank: 30Rank: 30Rank: 30Rank: 30Rank: 30

积分
39895

灌水勋章宣传勋章

发表于 2013-10-25 19:46 | 显示全部楼层
路过进来看看,看不太明白
回复 支持 反对

使用道具 举报

31

主题

463

铜板

6

好友

助理工程师

Rank: 5Rank: 5

积分
393
QQ
 楼主| 发表于 2014-1-22 15:14 | 显示全部楼层

是不是有点不明觉厉呢
回复 支持 反对

使用道具 举报

1

主题

7377

铜板

21

好友

高级工程师

Rank: 9Rank: 9Rank: 9

积分
1051
发表于 2014-1-30 23:10 手机频道 | 显示全部楼层
貌似很复杂的样子
回复 支持 反对

使用道具 举报

46

主题

5371

铜板

9

好友

高级工程师

Rank: 9Rank: 9Rank: 9

积分
1096
发表于 2014-3-19 23:00 | 显示全部楼层
好东西,收藏了
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

在线客服
快速回复 返回顶部 返回列表