openlayers加载MapServer地图服务

引入proj4脚本文件

<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.4/proj4.js"></script>
这里加载的坐标是EPSG:4527的Mapserver的地图服务代码如下
<div id="viewDiv"></div>
<script>
    proj4.defs('EPSG:4527', '+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=39500000 +y_0=0 +ellps=GRS80 +units=m +no_defs');
    var proj4527 = ol.proj.get('EPSG:4527');
    proj4527.setExtent([506665.4500395897,305104.5729758957,507945.7690395897,306991.48897589574]);
    var view=new ol.View({
        projection: 'EPSG:4527',
        center: [506865, 305504],
        zoom: 4
    });
    // 这里放置Mapserver服务链接,我用的是本地的链接
    var url = 'https://localhost:6443/arcgis/rest/services/testcgcs2000/testcgcs2000/MapServer';
    var layers2 = [
        new ol.layer.Image({
            source: new ol.source.ImageArcGISRest({
                ratio: 1,
                params: {},
                url: url,
                projection: 'EPSG:4527'
            })
        })
    ];
    var map = new ol.Map({
        layers:layers2,
        target: 'viewDiv',
        controls: ol.control.defaults({"attribution": false}).extend([new ol.control.FullScreen(),new ol.control.OverviewMap()]),
        view: view
    });

当时运行时图不显示,没有报错,后来换了一个服务就好了。
这里也相当于实现openlayers的坐标系转换了,下面是其他坐标系的EPSG proj4格式。

EPSG proj4格式定义列表
# Xian 1980
<4610> +proj=longlat +a=6378140 +b=6356755.288157528 +no_defs  <>
# China Geodetic Coordinate System 2000
<4490> +proj=longlat +ellps=GRS80 +no_defs  <>
# WGS 84
<4326> +proj=longlat +datum=WGS84 +no_defs  <>
# CGCS2000 / Gauss-Kruger zone 13
<4491> +proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=13500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger zone 14
<4492> +proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=14500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger zone 15
<4493> +proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=15500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger zone 16
<4494> +proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=16500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger zone 17
<4495> +proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=17500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger zone 18
<4496> +proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=18500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger zone 19
<4497> +proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=19500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger zone 20
<4498> +proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=20500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger zone 21
<4499> +proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=21500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger zone 22
<4500> +proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=22500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger zone 23
<4501> +proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=23500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger CM 75E
<4502> +proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger CM 81E
<4503> +proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger CM 87E
<4504> +proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger CM 93E
<4505> +proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger CM 99E
<4506> +proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger CM 105E
<4507> +proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger CM 111E
<4508> +proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger CM 117E
<4509> +proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger CM 123E
<4510> +proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger CM 129E
<4511> +proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / Gauss-Kruger CM 135E
<4512> +proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 25
<4513> +proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=25500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 26
<4514> +proj=tmerc +lat_0=0 +lon_0=78 +k=1 +x_0=26500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 27
<4515> +proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=27500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 28
<4516> +proj=tmerc +lat_0=0 +lon_0=84 +k=1 +x_0=28500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 29
<4517> +proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=29500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 30
<4518> +proj=tmerc +lat_0=0 +lon_0=90 +k=1 +x_0=30500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 31
<4519> +proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=31500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 32
<4520> +proj=tmerc +lat_0=0 +lon_0=96 +k=1 +x_0=32500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 33
<4521> +proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=33500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 34
<4522> +proj=tmerc +lat_0=0 +lon_0=102 +k=1 +x_0=34500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 35
<4523> +proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=35500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 36
<4524> +proj=tmerc +lat_0=0 +lon_0=108 +k=1 +x_0=36500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 37
<4525> +proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=37500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 38
<4526> +proj=tmerc +lat_0=0 +lon_0=114 +k=1 +x_0=38500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 39
<4527> +proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=39500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 40
<4528> +proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=40500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 41
<4529> +proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=41500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 42
<4530> +proj=tmerc +lat_0=0 +lon_0=126 +k=1 +x_0=42500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 43
<4531> +proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=43500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 44
<4532> +proj=tmerc +lat_0=0 +lon_0=132 +k=1 +x_0=44500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger zone 45
<4533> +proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=45500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 75E
<4534> +proj=tmerc +lat_0=0 +lon_0=75 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 78E
<4535> +proj=tmerc +lat_0=0 +lon_0=78 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 81E
<4536> +proj=tmerc +lat_0=0 +lon_0=81 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 84E
<4537> +proj=tmerc +lat_0=0 +lon_0=84 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 87E
<4538> +proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 90E
<4539> +proj=tmerc +lat_0=0 +lon_0=90 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 93E
<4540> +proj=tmerc +lat_0=0 +lon_0=93 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 96E
<4541> +proj=tmerc +lat_0=0 +lon_0=96 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 99E
<4542> +proj=tmerc +lat_0=0 +lon_0=99 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 102E
<4543> +proj=tmerc +lat_0=0 +lon_0=102 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 105E
<4544> +proj=tmerc +lat_0=0 +lon_0=105 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 108E
<4545> +proj=tmerc +lat_0=0 +lon_0=108 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 111E
<4546> +proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 114E
<4547> +proj=tmerc +lat_0=0 +lon_0=114 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 117E
<4548> +proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 120E
<4549> +proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 123E
<4550> +proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 126E
<4551> +proj=tmerc +lat_0=0 +lon_0=126 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 129E
<4552> +proj=tmerc +lat_0=0 +lon_0=129 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 132E
<4553> +proj=tmerc +lat_0=0 +lon_0=132 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
# CGCS2000 / 3-degree Gauss-Kruger CM 135E
<4554> +proj=tmerc +lat_0=0 +lon_0=135 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs  <>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值