Select to view content in your preferred language

Select with Feature Layer issue

3668
4
12-31-2013 07:11 AM
JosephFedor
Deactivated User
I???m brand new at developing with dojo and ArcGIS, so bear with me.  But I am sure enjoying what I am learning so far! 

I looked through some other posts; but didn???t find someone with exactly the same issue I???ve had.  I???ve been attempting to create a project very similar to the ???Select with Feature Layer??? example in the Samples (under ???Query and Select???).  

When I click on the ???View Live Sample??? link for this example, it works as expected.   I can click on the map, and a circle is drawn.  Then within the circle???s radius little pink dots appear for the different lots.  

After I tried it online, I downloaded the source code; and attempted to run the web page on my own box, and then from our server.  But in both cases the result was the same:  I could click on the map, and the circle was drawn, but no pink dots appeared inside of it. 

I thought I would also try using ???Explore in the sandbox???.  But I experienced the very same problem. 
What could I be missing?  Do I need to have my own copy of a certain file with the data for the pink dots? 

Thanks,
jfedor
0 Kudos
4 Replies
KenBuja
MVP Esteemed Contributor
Did you set up a proxy page? If you examine the code, it contains this

        // use a proxy page if a URL generated by this page is greater than 2000 characters
        //
        // using a polygon (the buffer returned from the geometry service) as a query geometry
        // will generate a long url as all vertexes from the geometry are sent to the service as 
        // part of the URL
        //
        // if proxyUrl is null or undefined the featureLayer.selectFeatures call will not work
        esriConfig.defaults.io.proxyUrl = "/proxy";
0 Kudos
JosephFedor
Deactivated User
Thanks for responding so soon to my question.  Sorry I haven�??t replied sooner. 

I don�??t have a proxy page set up; I think that�??s my problem.

I attempted to add it but it�??s not working.  So I�??ve been doing some debugging (with firebug and chrome tools) and I�??m getting a couple errors.  When I first load up the page I get this error:

XMLHttpRequest cannot load http://services.arcgisonline.com/ArcGIS/rest/info?f=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://inside_web' is therefore not allowed access. featureLayer.html:1
XMLHttpRequest cannot load http://sampleserver1.arcgisonline.com/ArcGIS/rest/info?f=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://inside_web' is therefore not allowed access. featureLayer.html:1
XMLHttpRequest cannot load http://tasks.arcgisonline.com/ArcGIS/rest/info?f=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://inside_web' is therefore not allowed access. featureLayer.html:1



I think it may be related to the proxy page. 

Then when I click on the map I get the error (described at the end of:  https://developers.arcgis.com/en/javascript/jshelp/ags_proxy.html). Except it�??s not a 404 not found error.  It�??s a 500 error that looks like this:

r {stack: "Error: Unable to load proxy.php?http://sampleserve�?�uest.e (http://js.arcgis.com/3.8/init.js:160:133)", message: "Unable to load proxy.php?http://sampleserver1.arcg�?�ics/ESRI_Census_USA/MapServer/0/query status: 500", response: Object, status: 500, responseText: "cURL extension for PHP is not loaded! <br/> Add th�?�tion&gt;/ext&quot; <br/> extension = php_curl.dll"�?�}
_ssl: undefined
log: undefined
message: "Unable to load proxy.php?http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/0/query status: 500"
response: Object
responseText: "cURL extension for PHP is not loaded! <br/> Add the following lines to your php.ini file: <br/> extension_dir = &quot;&lt;your-php-install-location&gt;/ext&quot; <br/> extension = php_curl.dll"
stack: "Error: Unable to load proxy.php?http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/0/query status: 500�?�    at Error (<anonymous>)�?�    at new r (http://js.arcgis.com/3.8/init.js:221:367)�?�    at r [as handleResponse] (http://js.arcgis.com/3.8/init.js:156:280)�?�    at XMLHttpRequest.e (http://js.arcgis.com/3.8/init.js:160:133)"
status: 500
xhr: XMLHttpRequest
__proto__: a



Anyway, that�??s where I�??m stuck at now.  Thanks
jfedor
0 Kudos
JakubMalec
Deactivated User
Your proxy error says that your curl extension for PHP is not enabled (curl is a library used for making http requests). To enable it, you simply need to uncomment "extension=php_curl.dll" (removing the ";" in the beginning) line in your php.ini file which is located in your PHP directory.

Also, remember to edit your proxy.php file and add approporiate hosts to the $serverUrls array or set the $mustMatch variable to false (not recommended).
0 Kudos
JosephFedor
Deactivated User
Thanks, that was the issue. 

In the chrome developer tools I can see that the POST to the proxy page is successful.  And (even better) the example works on our server!  I can see all the dots display just like it should. 

But there still are some GET requests that aren't working (though they don�??t seem to be affecting performance at all). 
These are the errors I get:


XMLHttpRequest cannot load http://services.arcgisonline.com/ArcGIS/rest/info?f=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'my server' is therefore not allowed access.
XMLHttpRequest cannot load http://sampleserver1.arcgisonline.com/ArcGIS/rest/info?f=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'my server' is therefore not allowed access.


I don�??t really understand why I these errors appear.  This is what my serverUrls array looks like in my proxy page:

[PHP]
  $serverUrls = array(
    array( 'url' => 'http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/', 'matchAll' => true, 'token' => '' ),
    array( 'url' => 'http://sampleserver2.arcgisonline.com/ArcGIS/rest/services/', 'matchAll' => true, 'token' => '' ),
    array( 'url' => 'http://sampleserver1a.arcgisonline.com/arcgisoutput/',        'matchAll' => true, 'token' => '' ),
    array( 'url' => 'http://sampleserver1b.arcgisonline.com/arcgisoutput/',        'matchAll' => true, 'token' => '' ),
    array( 'url' => 'http://sampleserver1c.arcgisonline.com/arcgisoutput/',        'matchAll' => true, 'token' => '' ),
array( 'url' => 'http://services.arcgisonline.com/ArcGIS/rest/',    'matchAll' => true, 'token' => '' ),
array( 'url' => 'http://tasks.arcgisonline.com/ArcGIS/rest/',    'matchAll' => true, 'token' => '' )
  );
[/PHP]


Thanks,
jfedor
0 Kudos