<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"> <title></title> <link rel="stylesheet" href="http://js.arcgis.com/3.9/js/esri/css/esri.css"> <style> html, body, #map { height: 100%; width: 100%; margin: 0; padding: 0; } #search { display: block; position: absolute; z-index: 3; top: 20px; left: 75px; } #display { padding-top:200px; } </style> <script src="http://js.arcgis.com/3.9/"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script> require([ "esri/map", "esri/dijit/Geocoder", "dojo/dom", "dojo/domReady!" ], function( Map, Geocoder, dom ) { // create a map and instance of the geocoder widget here var myGeocoders = [{ url: "http://gis.ci.fayetteville.nc.us/arcgis/rest/services/Composite_Locator/GeocodeServer", name: "Composite_Locator", singleLineFieldName: "Street" }]; var geocoder = new Geocoder({ autoComplete: true, arcgisGeocoder: false, geocoders: myGeocoders }, dom.byId("search")); // map.on("load", enableSpotlight); geocoder.on("select", showLocation); // geocoder.on("clear", removeSpotlight); function showLocation(evt) { // console.log(evt) $('#display').append(evt.result.name); // console.log(evt.result.name) } }); </script> </head> <body class="soria"> <div id="search"></div> <div id="display"></div> </body> </html>
Solved! Go to Solution.
geocoder.on('find-results', showLocation) function showLocation(evt) { if(evt.results.results.length > 0){ $('#display').append(evt.results.results[0].name); } else{ $('#display').append("No Information"); } }
geocoder.on('find-results', showLocation) function showLocation(evt) { if(evt.results.results.length > 0){ $('#display').append(evt.results.results[0].name); } else{ $('#display').append("No Information"); } }