Hello
I'm trying to use a javascript locator object with a geocode server of ArcGIS Online: http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Locators/ESRI_Geocode_EU/GeocodeServer
When I call the method locator.addressToLocations(options), I get the cross-domain problem.
locator.addressToLocations(options)
Is there a way to avoid this?
Is this a similar issue?
arcgis server - ESRI proxy page not working properly + CORS + cross domain scripting - Geographic Information Systems St…
I'm using ArcGIS Online services exclusively. I don't have a server. So I can't create a server proxy.
sampleserver1 doesn't support CORS so you're out of luck. (also, you should only have a cross domain problem when the resulting URL will be more than 2000 characters long, in which case a POST request is made. If it's less a JSONP request is made which won't suffer from cross domain issues)
I tried using this example:
loc = new Locator("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Locators/ESRI_Geocode_USA/GeocodeServer");
var address = {"Single Line Input": "100 main street"};
var params = {address: address};
loc.outSpatialReference= map.spatialReference;
loc.addressToLocations(params, function(e){
console.log("success: " + e);
},
function(e){
console.log("error: " + e);
});
But I get in the console the cross-domain warning saying that the request was blocked.
I get also "success: ". Which mean that e is empty.
did you try to add crossdomain.xml in your webserver and your project ? try this option..
I'm developing using salesforce and ArcGIS Online. I don't have access to any webserver.
You don't have a cross domain problem... The fact that you get a "success: " mean your request came through but the geocoder just didn't find a match. The geocoder you use doesn't support single line address input. See Locator - JSFiddle for a working example.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.