Select to view content in your preferred language

GeoCode Widget

1131
4
08-26-2013 08:16 AM
JohnBrady
Deactivated User
Anyone know how would I go about utilizing ESRI's geocode capabilities in a pre-built seaerch box?...the code below is our function with the GeoCode widget added.  However, the behavior isn't quite correct.  I'd like to configure our search box & button to hit the ESRI geocoder

function searchAddress(address) {
    function init() {
        geocoder = new esri.dijit.Geocoder({
            map: map,
            autoComplete: true,
            arcgisGeocoder: {
                name: "Esri World Geocoder",
                suffix: " Staunton, VA"
            }
        }, "AddressSearchButton");
        geocoder.startup();
    }
    dojo.ready(init);
}
0 Kudos
4 Replies
TrevorHavelka
Deactivated User
John,

The way the code is setup, you should be auto completing in a div with an id="AddressSearchButton" that is auto completing for addresses in Staunton, VA.  What is your expected output?
0 Kudos
JohnBrady
Deactivated User
"The way the code is setup, you should be auto completing in a div with an id="AddressSearchButton" that is auto completing for addresses in Staunton, VA.  What is your expected output?"

Afternoon Trevor, thanks for repsonding...

The behavior I am seeing is when executing the search in the text box, the code then initiates a "sub-Text box (see attachment)

here is the <div> statement

<div id="SearchDialog" data-rel="dialog" title="<i class='icon-search icon-large'></i>  Map Search" class="after-load">
    <form id="SearchForm" onsubmit="mapSearch($('#AddressSearchText').val());return false;">
        <input id="AddressSearchText" type="text" class="search-query" placeholder="Search for: Street Addresses" />
        <button id="AddressSearchButton" class="btn btn-primary"><i class="icon-search"></i></button>
    </form></div>
0 Kudos
TrevorHavelka
Deactivated User
I don't believe you need the button.  Change your JS to point to the id="AddressSearchText" textbox and the geocoder should render properly. 

function searchAddress(address) {
function init() {
geocoder = new esri.dijit.Geocoder({
map: map,
autoComplete: true,
arcgisGeocoder: {
name: "Esri World Geocoder",
suffix: " Staunton, VA"
}
}, "AddressSearchText");
geocoder.startup();
}
dojo.ready(init);
}
0 Kudos
JohnBrady
Deactivated User
I had tried that already and it didn't work

I am going to try downloading the dijit css and change the reference there
0 Kudos