2

I am having issues trying to set up a geocoder/locator on my server. I keep getting an error SyntaxError {log: undefined, stack: (...), message: "Unexpected token <"}, but I can't seem to figure out why. I tried exploring the error message, but I don't get much good information out of it.

I have tried using ESRI's geocoder widget then created my own set up using the locator service. I have checked my address string, and I believe it should be passing correctly over to the server.

If I am understanding the error message right, it is saying there is a token "<" somewhere that shouldn't be there, but I cannot find it.

Other info... I am running version 9.3.1 for my server, using the JavaScript API 3.8 that ESRI hosts, and created an address locator on my server using street centerlines for the area I am mapping.

Has anyone run into this issue before or have suggestions for me? Right now, I am just trying to center the map on the location. Once I get that done, I can worry about all the other stuff.

My code for the locator is below.Here is my development site.

 /////////////////////////////////////////////////////////////////
locator = new Locator(singleFieldGeocodeURL);
//add handler for completion
locator.on("address-to-locations-complete", showResults);
//trying to find the error
locator.on("error", function (error) {
 errorObject = error;
 console.log("error" + error);
});
//add handler for button click
on(dom.byId('locate'), 'click', function () {
 console.log(dom.byId('address').value);
 map.graphics.clear();
 var address = {
 "SingleLine": dom.byId('address').value
 };
 locator.outSpatialReference = map.spatialReference;
 var options = {
 address: { street: address },
 outFields: ["Loc_name"]
 };
 locator.addressToLocations(options);
});
function showResults(evt) {
 console.log("in show results");
 var candidate;
 var symbol = new SimpleMarkerSymbol();
 symbol.setStyle(SimpleMarkerSymbol.STYLE_SQUARE);
 symbol.setColor(new Color([153, 0, 51, 0.75]));
 var geom;
 arrayUtils.event(evt.addresses, function (candidate) {
 console.log(candidate.score);
 if (candidate.score > 80) {
 console.log(candidate.location);
 var attributes = {
 address: candidate.address,
 score: candidate.score,
 locatorName: candidate.attributes.Loc_name
 };
 geom = candidate.location;
 var graphic = new Graphic(geom, symbol, attributes, null);
 map.graphics.add(graphic);
 return false;
 }
 });
 if (geom !== undefined) {
 map.centerAndZoom(geom, 12);
 }
}
asked Jul 10, 2014 at 15:47

1 Answer 1

3

you are providing an invalid url to your locator service in your code.

"https://www.cartotronics.com/ArcGIS93/services/UTC_Viewers/Louisville_AlphaNumeric_Ranges/GeocodeServer"
//should be
"https://www.cartotronics.com/ArcGIS93/rest/services/UTC_Viewers/Louisville_AlphaNumeric_Ranges/GeocodeServer"

just as an aside, it would have been substantially less painful to help you debug the error related to your locator if you had provided more than a mysterious variable name in your code snippet or a link to an app without code that had already been minified.

answered Jul 12, 2014 at 16:09
2
  • Thanks! I do apologize for leaving my code minified. I totally forgot I had it set up to minify when I was saving it. I didn't even think it was related to my URL, but it is the simple mistakes that get me. Commented Jul 14, 2014 at 12:03
  • no worries at all Branco. glad to help :) Commented Jul 14, 2014 at 22:45

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.