ArcGIS API for Silverlight implements map ranging capabilities

Source: Internet
Author: User
Tags polyline silverlight

Original: ArcGIS API for Silverlight implements map ranging function

Question: How to achieve the map ranging function?


Map Toolbar


 <grid x:name= "Gtoolmenu" height= "verticalalignment=" "Top" opacity= "0.8" horizontalalignment= "right" Width= " 467 "> <rectangle fill=" #22919191 "radiusx=" "radiusy=" "margin=" > 0,0,0,6 Angle. effect> <DropShadowEffect/> </Rectangle.Effect> </rectangle            > <rectangle fill= "#CCFFFFFF" stroke= "Darkgray" radiusx= "5" radiusy= "5" margin= "5,10,5,10"/> <stackpanel orientation= "Vertical" > <esri:toolbar x:name= "Mytoolbar" maxitemheight= "$" maxitem Width= "verticalalignment=" Top "horizontalalignment=" Center "loaded=" Mytoolbar_lo                     aded "toolbaritemclicked=" mytoolbar_toolbaritemclicked "width=" 458 "height=" >                            <esri:Toolbar.Items> <esri:ToolbarItemCollection> <esri:toolbAritem text= "Zoom in" > <esri:ToolbarItem.Content> <image source= "Images/i_zoomin.png" stretch= "Uniform" margin= "5"/> </esri:tool baritem.content> </esri:ToolbarItem> <esri:toolbaritem T ext= "Zoom out" > <esri:ToolbarItem.Content> < Image source= "Images/i_zoomout.png" stretch= "Uniform" margin= "5"/> </esri:toolbarite m.content> </esri:ToolbarItem> <esri:toolbaritem text= "P An "> <esri:ToolbarItem.Content> <image SOURC                          E= "Images/i_pan.png" stretch= "Uniform" margin= "5"/> </esri:ToolbarItem.Content>  </esri:ToolbarItem> <esri:toolbaritem text= "Measure Length" > <esri:ToolbarItem.Content> <image source= "Images/i_measure.png" Mar gin= "5" > <i:interaction.                                                triggers> <i:eventtrigger eventname= "MouseLeftButtonDown" > <esri:measureaction targetname= "MyMap" areaunit= "Squaremeters" measuremode= "Polyli Ne "distanceunit=" kilometers "fillsymbol=" {StaticResource defaultfillsymbol} "displaytotals=" True "mapunits="                                        Kilometers "/> </i:EventTrigger> </i:interaction. Triggers> </Image> </esri:toolbaritem.conten         T> </esri:ToolbarItem>                   <esri:toolbaritem text= "Previous Extent" > <esri:toolbaritem.co ntent> <image source= "images/i_previous.png" ishittestvisible= "False" opacity= "0.                            3 "stretch=" Uniform "margin=" 5 "/> </esri:ToolbarItem.Content>                                </esri:ToolbarItem> <esri:toolbaritem text= "Next Extent" > <esri:ToolbarItem.Content> <image source= "Images/i_next.png" Ishi Ttestvisible= "False" opacity= "0.3" stretch= "Uniform" margin= "5"/> </esri:toolbaritem. content> </esri:ToolbarItem> <esri:toolbaritem text= "Ful  L Extent "> <esri:ToolbarItem.Content> <image Source= "Images/i_globe.PNG "stretch=" Uniform "margin=" 5 "/> </esri:ToolbarItem.Content>                                </esri:ToolbarItem> <esri:toolbaritem text= "full Screen" >  <esri:ToolbarItem.Content> <image source= "Images/i_widget.png"                            Stretch= "Uniform" margin= "5"/> </esri:ToolbarItem.Content> </esri:ToolbarItem> </esri:ToolbarItemCollection> </esri:to Olbar. items> </esri:Toolbar> </StackPanel> </Grid>

Above is the toolbar code, ranging from the XAML code extracted from the following:

<esri:toolbaritem text= "Measure Length" >     <esri:ToolbarItem.Content>               <image source= "images/ I_measure.png "margin=" 5 ">                       <i:interaction. triggers>                               <i:eventtrigger eventname= "MouseLeftButtonDown" >                                      <esri:measureaction TargetName= " MyMap "areaunit=" squaremeters "  measuremode=" Polyline "distanceunit=" kilometers "   fillsymbol=" { StaticResource Defaultfillsymbol} "  displaytotals=" True "mapunits=" kilometers "/>                              </i:eventtrigger >                        </i:interaction. triggers>               </Image>     </esri:ToolbarItem.Content> </esri:ToolbarItem>


Code Analysis:

Add triggers for picture image, listen for image's left mouse button press event, then execute measureaction, Target is Mymap map, measure is polyline, unit is kilometer (kilometers), symbol uses a static resource.


<esri:toolbaritem text= "Measure Length" >
<esri:ToolbarItem.Content>
<image source= "Images/i_measure.png" margin= "5" >
<i:interaction. Triggers>
<i:eventtrigger eventname= "MouseLeftButtonDown">
<esri:measureaction targetname= "MyMap"Areaunit="squaremeters"Measuremode="Polyline"Distanceunit="kilometers"Fillsymbol=" {StaticResource Defaultfillsymbol} "
displaytotals= "True" mapunits= "kilometers"/>
</i:EventTrigger>
</i:interaction. Triggers>
</Image>
</esri:ToolbarItem.Content>
</esri:ToolbarItem>


When you press the ranging button, you can draw a line ranging on the map, the effect is as follows:


Note: Other places to be aware of references

Xmlns:esri= "http://schemas.esri.com/arcgis/client/2009"
Xmlns:i= "Clr-namespace:system.windows.interactivity;assembly=system.windows.interactivity"

<Grid.Resources>

<esri:simplefillsymbol x:key= "Defaultfillsymbol" borderbrush= "Red" borderthickness= "1"/>
</Grid.Resources>


===========================================================================

If you find it helpful, scan for support:




ArcGIS API for Silverlight implements map ranging capabilities

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.