我动态检索具有latidude经度值的数组,需要将其计算到范围内,以便它们完全适合地图(Adobe Flex)。我在Esri Map组件中使用的图层现在是:
<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><!-- background colors -->
<fx:String>1</fx:String><!-- signs -->
<fx:String>2</fx:String><!-- red overview road map can be outcommented-->
<fx:String>3</fx:String><!-- lines -->
</s:ArrayList>
</esri:visibleLayers>
</esri:WMSLayer>
在我使用标准Esri图层之前......
<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}"/>
..我可以使用WebMercatorExtent类来创建一个适合的扩展,但现在我需要使用这些层并且不能使用WebMercatorExtent,因为服务&#34; http://services.arcgisonline.nl/arcgis/rest/services/Basiskaarten/PDOK_BRT/MapServer&# 34;使用
<esri:SpatialReference id="wgs" wkid="28992"/>
与WebMercatorExtent没有关系。任何人都知道如何将此com.esri.ags.geometry.WebMercatorExtent转换为范围?
答案 0 :(得分:1)
听起来你需要将经度/纬度范围转换为空间参考28992中的范围,对吧?如果是,请参阅the Flex sample on projecting geometries。特别是看projectNow函数。它使用GeometryService.project将点从一个坐标系投影到另一个坐标系。您可以使用相同的函数将范围从一个坐标系统投影到另一个坐标系。
答案 1 :(得分:1)
以下是如何在代码中完成的。您需要声明为使用某些外部Web服务的GeometryService。这个是来自Esri的样本服务,当您阅读此答案时可能会出现故障,因为已经进行了升级。最好是使用你自己的arcgis服务,现在我使用了这个:
http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer
投入声明
<fx:Declarations>
<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"/>
</fx:Declarations>
然后创建WebMercatorExtent,创建一个您想要将Geometry转换为并将其投影的SpatialReference。网络服务将提供答案......
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);
...在函数中
protected function projectCompleteHandler(event:GeometryServiceEvent):void
{
try
{
// Note: As of version 2.0, GeometryService returns geometries (instead of graphics)
var extent:Extent = (event.result as Array)[0] as Extent;
map.extent = extent;
}
catch (error:Error)
{
Alert.show(error.toString());
}
}