Last active
August 29, 2015 14:03
-
-
Save rpepato/badb16d1d5667e8488be to your computer and use it in GitHub Desktop.
Simple demonstration of geocode dijit usage with ArcGIS Javascript API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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>ArcGIS API for JavaScript | Simple Geocoding</title> | |
<script src="http://js.arcgis.com/3.9/"></script> | |
<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: 2; | |
top: 20px; | |
left: 74px; | |
} | |
</style> | |
<script> | |
require([ | |
"esri/map", | |
"esri/dijit/Geocoder", | |
"esri/symbols/SimpleMarkerSymbol", | |
"esri/graphic", | |
"dojo/domReady!" | |
], function(Map, Geocoder, SimpleMarkerSymbol, Graphic) { | |
var map = new Map("map", { | |
basemap: "streets", | |
center: [-46.6388, -23.5489], | |
zoom: 14 | |
}); | |
var geocoder = new Geocoder({ | |
autoComplete: true, | |
map: map, | |
}, "search"); | |
geocoder.startup(); | |
geocoder.on("select", function(item) { | |
drawResult(item.result.feature.geometry); | |
}); | |
function drawResult(point) { | |
var symbol = new SimpleMarkerSymbol(); | |
var graphic = new Graphic(point, symbol); | |
map.graphics.add(graphic); | |
} | |
}); | |
</script> | |
</head> | |
<body> | |
<div id="search"></div> | |
<div id="map"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment