计算与GeometryService WMTS层地图范围 [英] Calculate WMTS layer map extent with GeometryService

查看:350
本文介绍了计算与GeometryService WMTS层地图范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有WMTS背景图层,WMS图层和点的图形层的阵列。点已经wgs84latlng被用于计算图的程度坐标。

I have WMTS background layer, a WMS Layer and an array of points in a graphic layer. The points have wgs84latlng coordinates that are used to calculate the extent of the map.

不工作:

在计算了GeometryService的程度的WMS层很好地投射在它上面的只是它的上移,而不是对应的点在GraphicsLayer的GeometryService计算出的位置的位置...

When calculating the extent with a GeometryService the the wms layer is nicely projected on top of it only it's position is shifted upwards and not corresponding with the GeometryService calculated position of the points in the GraphicsLayer...

服务:

    <esri:GeometryService id="geometryService"
                          concurrency="last"
                          fault="geometryService_faultHandler(event)"
                          projectComplete="projectCompleteHandler(event)"
                          showBusyCursor="true"
                          url="http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer"/>

    <esri:GeometryService id="geometryService2"
                          concurrency="last"
                          fault="geometryService_faultHandler(event)"
                          projectComplete="projectCompleteHandler2(event)"
                          showBusyCursor="true"
                          url="http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer"/>

图层:

    <esri:ArcGISTiledMapServiceLayer id="arcgisonlineLayer" load="{trace(arcgisonlineLayer.version)}" 
                                     url="http://services.arcgisonline.nl/arcgis/rest/services/Basiskaarten/PDOK_BRT/MapServer"/>   

    <esri:WMSLayer url="{wmsLayerUrl}">
        <esri:visibleLayers>
            <s:ArrayList>
                <fx:String>0</fx:String><!-- GTG vlakken -->
                <fx:String>1</fx:String><!-- GTG lijnen -->
                <!--<fx:String>2</fx:String>--><!-- Provinciale wegen-->
                <fx:String>3</fx:String><!-- GTG punten -->
                <fx:String>4</fx:String><!-- Kilometrering -->
                <fx:String>5</fx:String><!-- Kilometrering -->
                <fx:String>6</fx:String><!-- Kilometrering -->
                <fx:String>7</fx:String><!-- Kilometrering -->
                <fx:String>8</fx:String><!-- Beheergebied -->
                <!--<fx:String>9</fx:String>--><!-- Eigendomsgebied -->
                <!--<fx:String>10</fx:String>--><!-- Onderhoudsgebied -->
            </s:ArrayList>
        </esri:visibleLayers>
    </esri:WMSLayer>

    <esri:GraphicsLayer id="lichtpuntLayer"  />

caculate程度:

caculate extent:

public function set mapItemBounds(value:Object):void
        {
            _mapItemBounds = value as LatLngBounds;

            if(_mapItemBounds)
            {
                var wmExtent:WebMercatorExtent = new WebMercatorExtent(
                    _mapItemBounds.getSouthWest().lng(),
                    _mapItemBounds.getSouthWest().lat(),
                    _mapItemBounds.getNorthEast().lng(),
                    _mapItemBounds.getNorthEast().lat());
                var outSR:SpatialReference = new SpatialReference(28992);
                const projectParameters:ProjectParameters = new ProjectParameters;
                projectParameters.geometries = [ wmExtent];
                projectParameters.outSpatialReference = outSR;
                geometryService.project(projectParameters);

            }
        }

在地图上的位置,计算分

calculate position points on map

override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
        {
            super.updateDisplayList(unscaledWidth, unscaledHeight);

            if(mapItemsProject) { 
                mapItemsProject = false;
                var mapItemGeometryArr:Array = new Array();
                for each(var mapItem:IMapItem in mapItems) {
                    var latlng:LatLng = new LatLng(mapItem.wgs84Lat, mapItem.wgs84Lon);
                    mapItemGeometryArr.push(latlng.mapPoint())
                }

                var outSR:SpatialReference = new SpatialReference(28992);
                const projectParameters:ProjectParameters = new ProjectParameters;
                projectParameters.geometries =  mapItemGeometryArr;
                projectParameters.outSpatialReference = outSR;
                geometryService2.project(projectParameters);
            }

工作的罚款:

...相比时使用默认arcgisonline.com worldSteetMap

...in comparison when using the default arcgisonline.com worldSteetMap.

图层:

<esri:ArcGISTiledMapServiceLayer id="serviceLayer"
        url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" 
        visible="{viewModeButtonBar.selectedIndex == 0}"/>

    <esri:ArcGISTiledMapServiceLayer 
        url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"
        visible="{viewModeButtonBar.selectedIndex == 1}"/>  

    <!--PDOK layer is incompatable with lichtpuntLayer and id="map". If lichtpuntLayer and another map in declarations it will show up-->
    <!--<esri:ArcGISTiledMapServiceLayer visible="true"
        url="http://services.arcgisonline.nl/arcgis/rest/services/Basiskaarten/PDOK_BRT/MapServer"/>-->


    <esri:WMSLayer url="{wmsLayerUrl}">
        <esri:visibleLayers>
            <s:ArrayList>
                <fx:String>0</fx:String><!-- GTG vlakken -->
                <fx:String>1</fx:String><!-- GTG lijnen -->
                <!--<fx:String>2</fx:String>--><!-- Provinciale wegen -->
                <fx:String>3</fx:String><!-- GTG punten -->
                <fx:String>4</fx:String><!-- Kilometrering -->
                <fx:String>5</fx:String><!-- Kilometrering -->
                <fx:String>6</fx:String><!-- Kilometrering -->
                <fx:String>7</fx:String><!-- Kilometrering -->
                <fx:String>8</fx:String><!-- Beheergebied -->
            </s:ArrayList>
        </esri:visibleLayers>
    </esri:WMSLayer>

    <esri:GraphicsLayer id="lichtpuntLayer"/>

计算范围:

        public function set mapItemBounds(value:Object):void
        {
            _mapItemBounds = value as LatLngBounds;

            if(_mapItemBounds)
            {
                map.extent = new WebMercatorExtent(
                    _mapItemBounds.getSouthWest().lng(),
                    _mapItemBounds.getSouthWest().lat(),
                    _mapItemBounds.getNorthEast().lng(),
                    _mapItemBounds.getNorthEast().lat());
            }
        }

任何人都知道这是为什么不工作?

Anyone knows why this is not working?

推荐答案

由于是用 RD_New结构的瓷砖地图您需要让GeometryService做的 DatumTransform 在经纬度点过,当你给他们;在我的情况Amersfoort_To_WGS_1984_2008_MB。此外,我不得不设置WKID为108457和transformForward为false(默认值)。

Because the is a tiled map with a RD_New structure you need to let the GeometryService do a DatumTransform on latlng points too when you send them; in my case "Amersfoort_To_WGS_1984_2008_MB". Also I had to set wkid to 108457 and transformForward to false (default).

            var projectParameters:ProjectParameters = new ProjectParameters();
            var datumTransform: DatumTransform = new DatumTransform();
            datumTransform.wkid = 108457;
            datumTransform.wkt = "Amersfoort_To_WGS_1984_2008_MB";
            projectParameters.outSpatialReference = new SpatialReference(28992);
            projectParameters.datumTransform = datumTransform;
            projectParameters.transformForward = false;
            projectParameters.geometries = [ webMercatorExtent ];
            geometryService1.project(projectParameters)

这篇关于计算与GeometryService WMTS层地图范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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