javascript - Fetch geometry of an Address Location -


if search textual address (let's address "305 quincy st ne"), how go doing in arcgis using arcgis api javascript?

my aim call function has geometry of place passed function argument.

function showlocation(evt) {     map.graphics.clear();     var point = evt.result.feature.geometry; // how value textual address?     .     .     . } 

use locator class. here's example:

<!doctype html> <html>   <head>     <meta http-equiv="content-type" content="text/html; charset=utf-8">     <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">     <title>using locator find address</title>     <link rel="stylesheet" href="https://js.arcgis.com/3.14/esri/css/esri.css">     <style>       html, body, #map {         height:100%;         width:100%;         margin:0;         padding:0;       }       body {         background-color:#fff;         overflow:hidden;         font-family:"trebuchet ms";       }       #search {         display: block;         position: absolute;         z-index: 2;         top: 20px;         left: 75px;       }      </style>      <script src="https://js.arcgis.com/3.14/"></script>     <script>       var map;       var locator;       var symbol;       var locatorurl = "https://geocode.arcgis.com/arcgis/rest/services/world/geocodeserver";       require([         "esri/map", "esri/tasks/locator", "esri/graphic",         "esri/color", "esri/symbols/simplemarkersymbol", "esri/symbols/simplelinesymbol",         "dijit/form/textbox", "dijit/registry", "dojo/on", "dojo/parser",         "dojo/keys",         "dojo/domready!"       ], function(         map, locator, graphic,         color, simplemarkersymbol, simplelinesymbol,         textbox, registry, on, parser,         keys       ) {         map = new map("map",{           basemap: "topo",           center: [-117.19, 34.05],           zoom: 13         });          locator = new locator(locatorurl);          symbol = new simplemarkersymbol(             simplemarkersymbol.style_circle,             20,             new simplelinesymbol(                 simplelinesymbol.style_solid,                 color.fromhex("#eeaa00"),                 3),             color.fromhex("#002255")         );                  parser.parse();         var box = registry.byid("textbox_address");         on(box, "keypress", function (evt) {             if (keys.enter == evt.keycode) {                 var addresstext = box.get("value");                  //this important part. call locator.addresstolocations.                 locator.addresstolocations({                     address: {                         singleline: addresstext                     }                 }, function (addresses) {                     //success                     if (0 == addresses.length) {                         alert("address not found");                     } else {                         var address = addresses[0];                         var pt = address.location;                         map.graphics.clear();                         map.graphics.add(new graphic(pt, symbol));                         map.centerat(pt);                     }                 }, function (error) {                     //failure                     alert("error: " + error);                 });             }         });       });     </script>   </head>   <body>     <div id="search">         <label for="firstname" style="background-color: white">address:</label>         <input type="text" name="textbox_address" value="808 travis st, houston tx"             data-dojo-type="dijit/form/textbox" id="textbox_address" />     </div>     <div id="map"></div>   </body> </html> 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -