Hi, I am using address-to-locations-complete event with our custom locator, now if I type wrong address or garbage address, and click find button, the locator task runs just fine and brought 0 result and then show an alert msg saying "Address not Found", first time it works fine but I input wrong address or garbage address again, the alert box comes up twice, and this goes on and on..which is very annoying, did any of you see this behavior? I will appreciate any help in this regard, thanks--AZIZA
I made a very simple bare bone app with only few lines of code in it, I am pretty sure you guys can replicate this issue.
var searchByAddress, showResultLocation;
require([
"esri/tasks/locator",
"dojo/domReady!"
], function (locator) {
esriConfig.defaults.io.alwaysUseProxy = false;
esriConfig.defaults.io.corsDetection = false;
esriConfig.defaults.io.corsEnabledServers.push("http://services.arcgisonline.com/");
esriConfig.defaults.io.corsEnabledServers.push("http://www.arcgis.com/");
var rvcLocator = new locator(locator);
searchByAddress = function () {
var address = {
SingleLine: document.getElementById("search").value
};
var options = {
address: address,
outFields: ["*"]
};
showResultLocation = function (evt) {
var resultLocations = evt.addresses.length;
if (resultLocations == 0) {
alert("No Address found");
return;
}
}
rvcLocator.on("address-to-locations-complete", showResultLocation);
rvcLocator.addressToLocations(options);
};
});
HTML
<!DOCTYPE html>
<html>
<head>
<title>ArcGIS API for JavaScript | Basic Search</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.14/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://js.arcgis.com/3.14/esri/css/esri.css">
<style>
html,
body,
#search {
display: block;
position: absolute;
z-index: 2;
top: 20px;
left: 74px;
}
</style>
<script src="http://js.arcgis.com/3.14/"></script>
<script src="JS/test.js"></script>
</head>
<body>
<input id ="search" type="text"/>
<input id="searchAddBtn" type="button" value="FIND" onclick="searchByAddress();"/>
</body>
</html>