Chris,
We did something similar on our citizen engagement app. They would enter an address and we would check it against our locator. Further, we would check it against our city boundary to see if the point fell within our city limits. If not we would not add it to the list of available choices.
Here is some code that shows how we did this:
// Address Locator for finding stops near an address
function searchAddresses() {
var address = {"SingleLine": $("#addrSearch").val()};
if (address.SingleLine != "") {
var params = {address: address, outFields:["*"]};
geocoder.addressToLocations(params, buildAddressList, errAddress);
} else {
$('#addressList li').remove();
selectedAddress = '';
}
}
function buildAddressList(geocodeResults) {
gcr = geocodeResults;
$('#addressList li').remove();
var titleLI = $('<li data-role="list-divider" data-inset="true" />');
titleLI.append("<h3 id='addListHeader'> Address List</h3>");
$('#addressList').append(titleLI);
var addCount = 0;
$.each(gcr, function(i, a) {
// we only want to display addresses that are in Yakima.
var pt = esri.geometry.geographicToWebMercator(new esri.geometry.Point(a.location.x, a.location.y));
// Check to see if the point is in the Yakima City Limits
var isYakima = yakimaCL.graphics[0].geometry.contains(pt);
if (isYakima == true) {
var li = $("<li />");
if (a.attributes.Addr_type == "Address") {
var content = "<a href='#' onClick='useAddress(" + i + ")'><h3>" + a.address + "</h3><p>" + a.attributes.User_fld + "</p><span class='ui-li-count'>" + a.score + "</span></a>";
} else {
var addr = a.address.split(",");
var content = "<a href='#' onClick='useAddress(" + i + ")'>" + addr[0] + "<span class='ui-li-count'>" + a.score + "</span></a>";
}
li.append(content);
//add the list item to the feature type list
$('#addressList').append(li);
addCount += 1;
}
});
//refresh the featurelist so the jquery mobile style is applied
$('#addressList').listview('refresh');
$("#addListHeader").html(" " + addCount + " found in Yakima");
}
I hope this is helpful.
Regards,
Tom