arcgis api for js 坐标转换.html

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>坐标转换</title>

    <link rel="stylesheet" href="https://js.arcgis.com/3.21/esri/css/esri.css">
    <script type="text/javascript" src="https://js.arcgis.com/3.21/"></script>
    <style>
        html,body,#map{
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }
    </style>
    <script>
        require([
                "esri/map",
                "esri/geometry/Point",
                "esri/geometry/Polyline",
                "esri/geometry/Polygon",

                "esri/tasks/GeometryService",
                "esri/symbols/SimpleMarkerSymbol",
                "esri/symbols/SimpleFillSymbol",
                "esri/symbols/SimpleLineSymbol",
                "esri/SpatialReference",

                "dojo/domReady!"],
            function(
                Map,Point,Polyline,Polygon,GeometryService,SimpleMarkerSymbol,
                SimpleFillSymbol,SimpleLineSymbol,SpatialReference
            ){

                var map = new Map("map",{
                    basemap: "osm",
                    center: [116.397245, 39.900930],
                    zoom:"6"
                });


                var points=[new Point(116.397245, 39.900930),new Point(117.055375, 39.056074)];
                var polylines=[new Polyline([[115.88,28.70],[115.88,28.67]]),new Polyline([[115.82,28.64],[115.89,28.59]])];
                var polygons=[new Polygon([[115.798499,28.783553],[115.75998,28.895433],[115.900834,28.821535],[115.785276,28.759237],[115.713987,28.733902]])];

                var geometryService = new GeometryService("https://utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
                // var geometryService = new GeometryService("http://60.28.130.106:6080/arcgis/rest/services/Utilities/Geometry/GeometryServer");
                var point = new Point(116.397245, 39.900930);
                console.log("point:", point);
                // {type: "point", x: 116.397245, y: 39.90093, spatialReference: {…}}
                // spatialReference: {wkid: 4326}
                // type: "point"
                // x: 116.397245
                // y: 39.90093
                geometryService.project([point], new SpatialReference(32650), function (point2) {
                    console.log("point2:", point2);
                    // [{…}]
                    // 0:
                    // spatialReference: {wkid: 32650}
                    // type: "point"
                    // x: 448474.56577950035
                    // y: 4416935.367997754
                });

                var polyline = new Polyline([[115.88,28.70],[115.88,28.67]]);
                console.log("polyline:", polyline);
                // polyline:
                // {type: "polyline", paths: Array(1), _path: 0, spatialReference: {…}}
                // paths: Array(1)
                // 0: Array(2)
                // 0: (2) [115.88, 28.7]
                // 1: (2) [115.88, 28.67]
                // length: 2
                // __proto__: Array(0)
                // length: 1
                // __proto__: Array(0)
                // spatialReference: {wkid: 4326}
                // type: "polyline"
                // _path: 0
                geometryService.project([polyline], new SpatialReference(32650), function (polyline2) {
                    console.log("polyline2:", polyline2);
                    // polyline2:
                    //     [{…}]
                    // 0:
                    // paths: Array(1)
                    // 0: Array(2)
                    // 0: (2) [390594.80196629325, 3175262.477018677]
                    // 1: (2) [390563.6102523839, 3171938.5444936673]
                    // length: 2
                    // __proto__: Array(0)
                    // length: 1
                    // __proto__: Array(0)
                    // spatialReference: {wkid: 32650}
                    // type: "polyline"
                    // _path: 0
                });
            });
    </script>
</head>

<body>
    <div id="map"></div>
</body>
</html>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值