Five application:labeling features

Source: Internet
Author: User

<! DOCTYPE html>"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="//js.arcgis.com/3.13/esri/css/esri.css"> <style>html, body, #map {height:100%; width:100%; margin:0; padding:0; }    </Style> <script src="//js.arcgis.com/3.13/"></Script> <script>varmap; Require (["Esri/map",         "Esri/geometry/extent",        "Esri/layers/featurelayer",        "Esri/symbols/simplelinesymbol",        "Esri/symbols/simplefillsymbol",        "Esri/symbols/textsymbol",        "Esri/renderers/simplerenderer",        "Esri/layers/labellayer",        "Esri/color",        "dojo/domready!"      ], function(Map, Extent, Featurelayer, Simplelinesymbol, Simplefillsymbol, Textsymbol, Simplerenderer, Labe Llayer, Color) {//load the map centered on the states        varBbox =NewExtent ({"Xmin":-1940058,"Ymin":-814715,"Xmax": 1683105,"Ymax": 1446096,"Spatialreference": {"Wkid": 102003}}); Map=NewMap ("Map", {extent:bbox}); varLabelField ="State_name"; //Create a renderer for the states layer to override default Symbology        varStatescolor =NewColor ("#f00"); varStatesline =NewSimplelinesymbol ("SOLID", Statescolor, 1); varStatessymbol =NewSimplefillsymbol ("SOLID", Statesline,NULL); varStatesrenderer =NewSimplerenderer (Statessymbol); //Create a feature layer to show country boundaries        varStatesurl ="HTTP://SAMPLESERVER6.ARCGISONLINE.COM/ARCGIS/REST/SERVICES/CENSUS/MAPSERVER/3"; varstates =NewFeaturelayer (Statesurl, {ID:"states", outfields: [LabelField]});        States.setrenderer (Statesrenderer);        Map.addlayer (states); //Create a text symbol to define the style of labels        varStateslabel =NewTextsymbol (). SetColor (NewColor ("#00f")); StatesLabel.font.setSize ("12pt"); StatesLabel.font.setFamily ("Arial"); varStateslabelrenderer =NewSimplerenderer (Stateslabel); varLabels =NewLabellayer ({ID:"Lab" }); //Tell the label layer to label the countries feature layer        //using the field named "Admin"Labels.addfeaturelayer (states, Stateslabelrenderer,"{"+ LabelField +"}"); //Add the label layer to the mapMap.addlayer (labels);    }); </Script> </head> <body> <div id="Map"></Div> </body></Html>

Five application:labeling features

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.