I want to use the findAddress Candidates, but I am receiving a syntax error. What do I need to modify?
<script> require(["esri/tasks/AddressCandidate", "dojo/_base/array"], function (AddressCandidate,array) { on(dom.byId("btnTest"),"click",function() { array.forEach(addressCandidates, function(candidate) { if (candidate.score > score && candidate.attributes.Loc_name === document.getElementById("ownerAddress").value) { stop = candidate; score = candidate.score; // Display the score on the console. console.log = score; } }) }); </script>
And the AddressCandidate code sample appear to be incomplete. What else do I need besides what they show. I figure my addressLocator; anything else?
Here is my updated code: csergent45/codeViolationNotice at 3cd51e07008dfb3882231ba9f252d81dbef05bae · GitHub
Solved! Go to Solution.
You're missing an additional "});" at the end. The following is syntactically correct:
require(["esri/tasks/AddressCandidate", "dojo/_base/array"], function (AddressCandidate,array) { on(dom.byId("btnTest"),"click",function() { array.forEach(addressCandidates, function(candidate) { if (candidate.score > score && candidate.attributes.Loc_name === document.getElementById("ownerAddress").value) { stop = candidate; score = candidate.score; // Display the score on the console. console.log(score); } }); }); });
I recommend you bookmark this page: The Online Lint - I use it many times per day.
Huh I've never seen console.log with '=', just console.log()
That was a mistake. I know better than to write assignment statements.
What is the syntax error that you're receiving? Where are you setting the variable score? The first time you run through the candidates in the foreach, is "candidate.score > score" getting evaluated properly?
It's in my prans and curly braces. I don't have it set right.
Yeah, don't do console.log = anything, you overwrite it and can just break the internet like that.
But on your original question, where the addressCandidates array coming from?
I think what you are trying to do is use the Locator Task.
If I reference the Locator Task, will I be able to use find Address Candidates? Say you owned every house on your block and had to enter each address on each line on an online form. I have to verify that each one of those addresses is correct or close. That's why I am trying to use Address Candidates.
But I am getting a syntax error from my code. Ignore the console.log line. I was in a rush, but there is a syntax error without that line. Any idea what it is?
I want to figure that out before I add more code.
Probably because addressCandidates is null. AddressCandidate is the data type for what is returned from a Locator, it doesn't do anything.
This is what you want
You're missing an additional "});" at the end. The following is syntactically correct:
require(["esri/tasks/AddressCandidate", "dojo/_base/array"], function (AddressCandidate,array) { on(dom.byId("btnTest"),"click",function() { array.forEach(addressCandidates, function(candidate) { if (candidate.score > score && candidate.attributes.Loc_name === document.getElementById("ownerAddress").value) { stop = candidate; score = candidate.score; // Display the score on the console. console.log(score); } }); }); });
I recommend you bookmark this page: The Online Lint - I use it many times per day.
Thanks. I bookmarked that. I still had a little bit of trouble following it, but at least it gives tips.