Esri / angular-esri-map

A collection of directives to help you use Esri maps and services in your Angular applications
https://esri.github.io/angular-esri-map/
Apache License 2.0
213 stars 107 forks source link

Using PortalItem Id instead of URL to create a new FeatureLayer produces an error. #312

Closed agileorange closed 8 years ago

agileorange commented 8 years ago

Intro

The portal item is correctly set up as it works as expected in the ArcGIS sandbox (https://developers.arcgis.com/javascript/latest/sample-code/sandbox/sandbox.html?sample=layers-portal)

Expected behaviour

Layer created and displayed correctly

Actual behaviour

Console Error:

esri/request: the first parameter should be a url string

Steps to reproduce the behaviour

Create a new layer using PortalItem Id.

                // and add a feature layer
                var aFeatureLayer = new FeatureLayer({
                    portalItem: {
                         id: '1a208242f5b74aacaf1d291bbfcac1aa'
                    }
                });
                vm.map.add(aFeatureLayer);
jwasilgeo commented 8 years ago

@agileorange, which version of JSAPI and which version of angular-esri-map are you using?

agileorange commented 8 years ago

As far as I know //npmcdn.com/angular-esri-map@2 //js.arcgis.com/4.0/ AngularJS v1.5.8

jwasilgeo commented 8 years ago

Thanks for the info. I think I am also seeing the error you are describing, but can you please provide a working code sample, like on jsfiddle, plnkr, etc. to re-create this in the way that you are experiencing it?

agileorange commented 8 years ago

Hi here is a plnkr sample https://plnkr.co/edit/aYyQNhlCx5EGIcp6yQRC?p=preview

The feature layer does include data that is shown clearly on the non-angular version (adapted - https://developers.arcgis.com/javascript/latest/sample-code/sandbox/sandbox.html?sample=layers-featurelayer)

agileorange commented 8 years ago

Hi @jwasilgeo - any further thoughts on this? I'm on a bit of deadline :-( and I was wondering if you will get a chance to look at this in the next day or two? Cheers!

jwasilgeo commented 8 years ago

Hey @agileorange yes I'll take a few shots at debugging this over the next day or two.

jwasilgeo commented 8 years ago

@agileorange can you switch your app to use the latest version of the new JSAPI? Try out 4.1 instead of 4.0 for your css and js. It just worked for me in your plnkr.

If this will work for you as well, then I'll hazard a guess that there may be subtle core differences between 4.0 and the latest 4.1 release when specifying a portalItem property in a FeatureLayer constructor. The main portalItem sample uses a slightly different style with Layer.fromPortalItem that appears to work with both 4.0 and 4.1 in the sandbox.

agileorange commented 8 years ago

@jwasilgeo - many thanks I've switched to 4.1 and all works a treat - thank you!