Search code examples
arcgisarcgis-js-api

ArcGIS Javascript 4.x add state boundary with feature layer


How to set the the following service api to the state boundary on the map.

https://esri.maps.arcgis.com/home/item.html?id=045485554d804e47b7972e49adacb4b8

Because I call the service url in the angular but the map keep showing the country boundary instead of the state boundary. Anyone can help me to solve this problem?

This is what I trying to do

enter image description here

This is what I get

enter image description here

This is the code: enter image description here

I guess it is something related to the layers attribute in the picture below, I just don't know how to choose the attribute there: enter image description here


Solution

  • That feature service has three layers. You can specify which one to use in the "url" parameter. If you don't point to a specific one, it will default to the first one - which in this case is the "country" layer - "0".

    In the URL to the FeatureLayer, change the ending from FeatureLayer to FeatureLayer/1 to display the Malaysia Negeri Boundaries.

    You'll probably also want to set the transparency on that layer and/or change the default renderer that layer has.

    https://www.arcgis.com/home/item.html?id=b7fda90324624e3b971fe98810be4091