gisempire100
捉鬼专家
捉鬼专家
  • 注册日期2004-08-13
  • 发帖数552
  • QQ
  • 铜币2462枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1542回复:0

Bing Maps在ArcGIS API for Flex中使用Bing Maps

楼主#
更多 发布于:2009-12-22 12:41
<P>Good-looking basemaps like Bing Maps (formerly known as Microsoft Virtual Earth) are key to providing your Web users with a pleasant user experience and context for your business information. With the ArcGIS API for Flex you can easily access worldwide high quality imagery and street maps from Bing Maps and display information from your own map services on top of them. Bing Maps is also great for supporting the display of advanced GIS analysis from ArcGIS Server services. In this post we will describe some simple steps to add Bing Maps to a Flash-based Web mapping application created with the ArcGIS API for Flex. </P>
<P><B>Getting Started</B></P>
<P>To add Bing Maps to your ArcGIS Flex applications, it is not required to directly work with Bing Web services. The API provides <a href="http://resources.esri.com/help/9.3/arcgisserver/apis/flex/apiref/index.html?com/esri/ags/virtualearth/package-detail.html;com/esri/ags/virtualearth/class-list.html" target="_blank" >classes</A> to add Bing Maps as basemaps and locate places using the Bing Maps geocoding service. Follow the steps below to get started:</P>
<OL>
<LI>Obtain your Bing Maps user name and password from your ArcGIS Server administrator.
<LI>Download and configure the "Get Virtual Earth Token" page that matches your development platform.
<LI>Specify the "Get Virtual Earth Token" page, or set "serverToken", to access Bing Maps<BR></LI></OL>
<P>For more information on these steps refer to the <a href="http://resources.esri.com/help/9.3/arcgisserver/apis/flex/help/index.html#ve_gettingstarted.htm?" target="_blank" >Getting Started</A> documentation.</P>
<P><B>Adding Bing Maps</B></P>
<P><B></B>The <a href="http://resources.esri.com/help/9.3/arcgisserver/apis/flex/apiref/index.html?com/esri/ags/virtualearth/VETiledLayer.html;com/esri/ags/virtualearth/class-list.html" target="_blank" >VETiledLayer</A> class allows you to easily add Bing Maps into your Flex applications. Below are MXML and ActionScript code to add Bing Maps to your application.</P>MXML to use Bing Maps:
<DIV><PRE>        <esri:Map><BR>             <esri:VETiledLayer<BR>                 environment="production"<BR>                 tokenURL=http://myserver:8081/ve/vetoken.jsp<BR>                 mapStyle="road"<BR>             /><BR>         </esri:Map></PRE></DIV>
<P>ActionScript to use Bing Maps:</P>
<DIV><PRE>             var veTiledLayer:VETiledLayer = new VETiledLayer();<BR>             veTiledLayer.tokenURL = "http://myserver:8081/ve/vetoken.jsp";<BR>             veTiledLayer.environment = "production";<BR>             veTiledLayer.mapStyle = VETiledLayer.MAP_STYLE_ROAD;<BR>             myMap.addLayer(veTiledLayer);</PRE></DIV>
<P>Now that you have Bing Maps in your map, you can display other information on top. For example you can add the results of a drive time analysis from an ArcGIS Server geoprocessing service. The code flow for the application will look like below. The complete code is <a href="http://serverapps.esri.com/flex/bing_with_arcgis_flex/bing_with_arcgis_flex.txt" target="_blank" >here</A>. <BR></P>
<DIV><PRE><IMG src="http://i.imagehost.org/0715/clip_image002.jpg" border=0></PRE><PRE><IMG src="http://blogs.esri.com/Dev/photos/2008_server/images/10641/original.aspx"> </PRE></DIV>
<P><B>Note:</B> Make sure when you create a Flex Builder project, you configure it to run from a Web server's virtual directory. If you run the application as a local file, the Bing Maps token handler will not recognize the referrer added in the token handler page.</P>
<P>You should also know that we are migrating all the ArcGIS Online map services to fit the Bing Maps tiling scheme, so you can combine any layer with Bing Maps. Of course, with the code above you also know how to combine Bing Maps with your own ArcGIS Server services!</P>
<P><B>Geocoding with Bing Maps</B></P>
<P>The ArcGIS API for Flex exposes Bing Maps geocoding through the <a href="http://resources.esri.com/help/9.3/arcgisserver/apis/flex/apiref/index.html?com/esri/ags/virtualearth/VEGeocoder.html;com/esri/ags/virtualearth/class-list.html" target="_blank" >VEGeocoder</A> class. Below is a code snippet for using Bing Maps geocoding in your application.</P>
<P>ActionScript to use Bing Maps geocoder:</P>
<DIV><PRE>            var veGeocoder:VEGeocoder = new VEGeocoder();<BR>            veGeocoder.environment = "production";<BR>            veGeocoder.tokenURL = "http://[MYSERVER/VE/vetoken.jsp]";<BR>            var query:String = "380 New York St, CA";<BR>            veGeocoder.addressToLocations(query);<BR>            veGeocoder.addEventListener(VEGeocoderEvent.ADDRESS_TO_LOCATIONS_COMPLETE,<BR>                function (event:VEGeocoderEvent):void{<BR>                    var veResult:VEGeocodeResult = event.results[0];<BR>                    myMap.extent = WebMercatorUtil.geographicToWebMercator(veResult.bestView) as Extent;<BR>                }<BR>            );</PRE></DIV>
<P>Observe from the code above that the ArcGIS API for Flex also has utility methods to convert the coordinates of the geocoding results between the geographic and Web Mercator coordinate systems. The Bing Maps geocoding service always returns the results in geographic coordinates, and you will need to convert them to the appropriate coordinate system of your basemap. </P>
<P>Click on the links below to view live samples that showcase the use of Bing Maps and the Bing Maps geocoding service. </P>
<UL>
<LI><a href="http://resources.esri.com/help/9.3/arcgisserver/apis/flex/samples/index.html?sample=VETiledLayer" target="_blank" >Bing Maps map styles</A>
<LI><a href="http://resources.esri.com/help/9.3/arcgisserver/apis/flex/samples/index.html?sample=VEGeocoder" target="_blank" >Bing Maps geocoder</A> </LI></UL>
<P>To get more information on using Bing Maps in your Flex applications, see <a href="http://resources.esri.com/help/9.3/arcgisserver/apis/flex/help/index.html#ve_gettingstarted.htm?" target="_blank" >Getting Started with Bing Maps in the ArcGIS API for Flex</A>.</P>
<P><I>Contributed by Antony Jayaprakash of the ArcGIS API for Flex development team.</I></P>
<DIV class=postfoot>Published Monday, December 21, 2009 5:35 PM by <a href="http://blogs.esri.com/Dev/user/Profile.aspx?UserID=2256" target="_blank" >sterlingdq</A>
<DIV>Filed under: <a href="http://blogs.esri.com/Dev/blogs/arcgisserver/archive/tags/Web+services/default.aspx" target="_blank" >Web services</A>, <a href="http://blogs.esri.com/Dev/blogs/arcgisserver/archive/tags/Flex/default.aspx" target="_blank" >Flex</A></DIV></DIV>
喜欢0 评分0
A friend is never known till a man has need. ...CL
游客

返回顶部