AnsweredAssumed Answered

dojo bootstrap typeahead - example

Question asked by schlot on Jul 29, 2015
Latest reply on Jul 30, 2015 by schlot

I am using this example as my starting point:  Dojo Bootstrap with ArcGIS JavaScript API - odoenet


I am not in a position to upgrade our servers to 10.3 to take advantage of including a featureLayer in my Search widget, at least not in time to meet my current deadline.  I'm hoping this code will do the trick for now.  It takes the text the enters and provides a list of suggestions based on what they've typed.  Once they select an item. the map centers on it. 


The user is likely to initiate a search while the map is still zoomed to the whole state, so I need it to both zoom and center.  I'm not wrapping my head around how to modify this code to accomplish this. 


<!DOCTYPE html>
  <meta charset="utf-8">
  <title>Auto Complete Find Example</title>
  <link rel="stylesheet" href="//">
<link rel="stylesheet" href="//">

<!-- Example found at
    #map {
   height: 500px;

#autocomplete {
  position: fixed;
  z-index: 99;
  left: 75px;
  top: 20px;
  background-color: #fff;
  padding: 10px;
  border: 1px solid #e3e3e3;
var dojoConfig = {
    packages: [{
        name: "bootstrap",
        location: "//"
<script src=""></script>
      <script type=text/javascript>     
], function(
        Map, query, Typeahead,
         FindParameters, FindTask,
) {
  var pathName = "";
 // var url = '';
  var url = pathName + '/arcgis/rest/services/DSS/medProvider/MapServer';
  var graphicsExtent = graphicsUtils.graphicsExtent;
  var asFeatures = function asFeatures(data) {
    return [data.feature];

  var findResult = function findResult(results, item) {
    return results.filter(function(x) {
      return x.value === item;
  var setExtent = function setExtent(map, features) {
    return map.setExtent(features);

  var map = new Map('map', {
    center: [-92.593, 38.5],
    zoom: 7,
    basemap: 'topo'
   var featureLayer = new FeatureLayer(url+"/0", {
            mode: FeatureLayer.MODE_SNAPSHOT,
            outFields: ['*']
  map.on('load', function() {
    var findTask = new FindTask(url);
    var params = new FindParameters();
    params.returnGeometry = true;
    params.outSpatialReference = map.spatialReference;
    params.layerIds = [0];
    params.searchFields = ['NA_PROVIDER'];
    var results;

    var node = document.getElementById('search');
      source: function(q, process) {
        params.searchText = q;
        findTask.execute(params).then(function(x) {
          results = x;
          process( {
            return a.value;
     updater: function(x) {
            asFeatures(findResult(results, x))
          return x;
  <div id="map">
    <div id="autocomplete">
        <label>Search For Provider:</label><br/>
<input id="search" type="text" class="span4"></input>