I'd like to know how to add multiple feature layers to a map? I tried syntax like the following, but only the last feature was added.
from arcgis.features import FeatureLayer
from arcgis.features import FeatureCollection
my_map4 = my_gis.map('Chicago', 9)
my_map4.basemap = 'osm'
f1 = FeatureLayer('http://xxx.com/arcgis/rest/services/Stage/crew_change_point_service/MapServer/0')
f2 = FeatureLayer('http://xxx.com/arcgis/rest/services/Stage/yard_service/MapServer/0')
my_map4.add_layer([f1, f2])
my_map4
Solved! Go to Solution.
The map widget should be displayed before layers are added to it. The following should work:
from IPython.display import display
from arcgis.features import FeatureLayer
from arcgis.features import FeatureCollection
my_map4 = my_gis.map('Chicago', 9)
my_map4.basemap = 'osm'
f1 = FeatureLayer('http://xxx.com/arcgis/rest/services/Stage/crew_change_point_service/MapServer/0')
f2 = FeatureLayer('http://xxx.com/arcgis/rest/services/Stage/yard_service/MapServer/0')
display(my_map4)
my_map4.add_layer([f1, f2])
The map widget should be displayed before layers are added to it. The following should work:
from IPython.display import display
from arcgis.features import FeatureLayer
from arcgis.features import FeatureCollection
my_map4 = my_gis.map('Chicago', 9)
my_map4.basemap = 'osm'
f1 = FeatureLayer('http://xxx.com/arcgis/rest/services/Stage/crew_change_point_service/MapServer/0')
f2 = FeatureLayer('http://xxx.com/arcgis/rest/services/Stage/yard_service/MapServer/0')
display(my_map4)
my_map4.add_layer([f1, f2])
It works like magic. Thank you!