Using AGS Map Services and JS Errors

672
1
02-01-2017 07:36 AM
JohnMax
New Contributor III

I am new to JavaScript but I managed to modify the sample code from the "Search using suggestion template" to create what I needed.  There are two issues I'm having, though.

1. I can only get the layers to display and be searchable if they are uploaded to ArcGIS Online.  When I reference the map services on our AGS in the code it doesn't work.  Is it because we are still using AGS 10.2.2 or will this not work with map services perhaps?

2. When our website administrator adds the code to our website, it generates JavaScript errors and the map will only load correctly maybe half the time.  It requires several refreshes to get it to load completely with the labels and search box sometimes.  Here's what he told me if this makes sense to anyone. 

It is a conflict between ArcGIS and two JS files from WordPress.

 Standalone, the ArcGIS map code doesn’t generate a JS error.  But mix it in with our WordPress framework and BAM!  JS error.  It is one of these two files:

 /wp-includes/js/imagesloaded.min.js?ver=3.2.0

/wp-includes/js/masonry.min.js?ver=3.3.2

 Error Message: “TypeError: b is undefined (masonry file 11:43)”

Thanks,

John

0 Kudos
1 Reply
RobertScheitlin__GISP
MVP Emeritus

John,

   Well I can answer question one.

The issue is that the suggest capability requires AGS 10.3 minumum

10.3 feature layer that supports pagination, i.e. supportsPagination = true

This is stated at the top of the JS API Search dijit doc:

Search | API Reference | ArcGIS API for JavaScript 3.19