< meta name = "viewport" content = "width=device-width, initial-scale=1, shrink-to-fit=no" />
< title >WebStyleSymbol (2D) | Sample | ArcGIS Maps SDK for JavaScript</ title >
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
< script type = "module" src = "https://js.arcgis.com/5.0/" ></ script >
< arcgis-zoom slot = "top-left" ></ arcgis-zoom >
< arcgis-bookmarks slot = "top-left" ></ arcgis-bookmarks >
< arcgis-legend slot = "bottom-right" ></ arcgis-legend >
const [ Map , FeatureLayer , Bookmark ] = await $arcgis . import ([
"@arcgis/core/layers/FeatureLayer.js" ,
"@arcgis/core/webmap/Bookmark.js" ,
// Get a reference to the map and bookmarks components
const viewElement = document . querySelector ( "arcgis-map" );
const bookmarksElement = document . querySelector ( "arcgis-bookmarks" );
// Get the category expression from the script tag
// This expression is used to categorize the points of interest
// based on their category field (cat2)
const category = document . getElementById ( "category" ). text ;
// Create a new map and set it to the view element
viewElement . map = new Map ({
viewElement . constraints = {
defaultPopupTemplateEnabled : true ,
await viewElement . viewOnReady ();
// Get the WebStyle symbol for each category
const rendererInfos = symbolCats . map (( symCat ) => {
styleName : "Esri2DPointSymbolsStyle" ,
// Create a renderer that uses the category expression to categorize the points of interest
type : "unique-value" , // autocasts as new UniqueValueRenderer()
valueExpression : category ,
valueExpressionTitle : "Symbol Categories" ,
uniqueValueInfos : rendererInfos ,
valueExpression : "$view.scale" ,
// Create a FeatureLayer to display the points of interest
const featureLayer = new FeatureLayer ({
url : "http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/LA_County_Points_of_Interest/FeatureServer/0" ,
// Add the FeatureLayer to the map
viewElement . map . add ( featureLayer );
// Set bookmarks for the map once the component is ready
await bookmarksElement . componentOnReady ();
bookmarksElement . bookmarks = [
name : "Angeles National Forest" ,
xmin : - 13139131.948889678 ,
xmax : - 13092887.54677721 ,
xmin : - 13125852.551697943 ,
ymin : 4066904.1101411926 ,
xmax : - 13114291.451169826 ,
ymax : 4077614.8487296384 ,
xmin : - 13185668.186639601 ,
xmax : - 13183855.195875114 ,
< script type = "text/plain" id = "category" >
if($feature.cat2 == "UPS Locations" || $feature.cat2 == "USPS Mail Collection Boxes" || $feature.cat2 == "DHL Locations" || $feature.cat2 == "Federal Express Locations"){
else if($feature.cat2=="Banking and Finance"){
else if($feature.cat2 == "Churches"){
return "place-of-worship"
else if($feature.cat2 == "Parks and Gardens"){
else if($feature.cat1 == "Education"){
else if($feature.cat2 == "Mental Health Centers" ||$feature.cat2 == "Medicare and Medicaid Offices"|| $feature.cat2 == "Mental Health Counseling" || $feature.cat2== "Dental Care" || $feature.cat2 == "Health Clinics" || $feature.cat2== "Health Centers" || $feature.cat2 == "Health Education and Counseling" || $feature.cat2== "Health Screening and Testing" || $feature.cat2== "Hospitals and Medical Centers"){
else if($feature.cat2 == "Fire Stations"){
else if($feature.cat2 == "Recreation Centers" || $feature.cat2 == "Recreation Programs" || $feature.cat2 == "Park and Ride Locations"){
else if($feature.cat2 == "Shopping Centers" || $feature.cat2=="Thrift Shops"){
else if($feature.cat2 == "Campgrounds"){
else if($feature.cat2 == "Golf Courses"){
else if($feature.cat2 == "Libraries"){
else if($feature.cat2 == "City Halls"|| $feature.cat2 == "Government Offices" || $feature.cat2 =="County Offices" || $feature.cat2 =="Probation Offices" || $feature.cat2 =="Social Security Administration"){
else if($feature.cat2 == "Beaches and Marinas"){
else if($feature.cat2 == "Sheriff and Police Stations"){
else if($feature.cat2 == "Metro Stations"){
else if($feature.cat2 == "Metrolink Stations" || $feature.cat2 == "Amtrak Stations"){
else if($feature.cat2 == "Cemeteries"){
else if($feature.cat2 == "Trails"){
else if($feature.cat2 == "Microwave Towers" || $feature.cat2 =="Cellular Towers"){
else if($feature.cat2 == "Museums and Aquariums"){
else if($feature.cat2 == "Airport"){
else if($feature.cat2 == "Cultural and Performing Arts Centers"){
return "live-music-venue"
else if($feature.cat2 == "Sports Venues"){
else if($feature.cat2 == "Ferries"){