Drag and drop sample - featureServices don't load?

2967
1
Jump to solution
11-24-2015 09:47 AM
TracySchloss
Frequent Contributor

In the CSV drag and drop example Drag and drop to display data | ArcGIS API for JavaScript  there is code that checks to see if you are dropping either a MapServer or FeatureServer.   It works for map services, but when I try a FeatureServer, setting a breakpoint within the handleDrop function's 'else if' statement, I never see it execute:

          else if (url.match(/(Map|Feature)Server\/\d+\/?$/i)) {

            // ArcGIS Server Map/Feature Service Layer?

            handleFeatureLayer(url);   //this never fires

          }

I'm not all that familiar with the more shortcut method of Javascript, so I'm not sure how to interpret the if statement.   Is this not supposed to work with FeatureServer and I'm just reading this wrong?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

That's a Regular Expression with its own type of syntax. There are some interpreters out there to decipher what that expression means. For example, this one ​reports this:

/(Map|Feature)Server\/\d+\/?$/i

  • 1st Capturing group (Map|Feature)
    • 1st Alternative: Map
      • Map matches the characters Map literally (case insensitive)
    • 2nd Alternative: Feature
      • Feature matches the characters Feature literally (case insensitive)
  • Server matches the characters Server literally (case insensitive)
  • \/ matches the character / literally
  • \d+ match a digit [0-9]
    • Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy]
  • \/? matches the character / literally
    • Quantifier: ? Between zero and one time, as many times as possible, giving back as needed [greedy]
  • $ assert position at end of the string
  • i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])

Unfortunately, I don't know why it doesn't return true with a valid layer in a FeatureService

Edit...

I ran this with this FeatureService layer and it did hit that function, so that syntax is working properly. You have to make sure you specify the layer, not just the service.

View solution in original post

1 Reply
KenBuja
MVP Esteemed Contributor

That's a Regular Expression with its own type of syntax. There are some interpreters out there to decipher what that expression means. For example, this one ​reports this:

/(Map|Feature)Server\/\d+\/?$/i

  • 1st Capturing group (Map|Feature)
    • 1st Alternative: Map
      • Map matches the characters Map literally (case insensitive)
    • 2nd Alternative: Feature
      • Feature matches the characters Feature literally (case insensitive)
  • Server matches the characters Server literally (case insensitive)
  • \/ matches the character / literally
  • \d+ match a digit [0-9]
    • Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy]
  • \/? matches the character / literally
    • Quantifier: ? Between zero and one time, as many times as possible, giving back as needed [greedy]
  • $ assert position at end of the string
  • i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])

Unfortunately, I don't know why it doesn't return true with a valid layer in a FeatureService

Edit...

I ran this with this FeatureService layer and it did hit that function, so that syntax is working properly. You have to make sure you specify the layer, not just the service.