function locate() { map.graphics.clear(); var address = {"SingleLine":dojo.byId("address").value}; locator.outSpatialReference= map.spatialReference; locator.addressToLocations(address,["Loc_name"]); } function showResults(candidates) { if(candidates.length === 0){ alert('no candidates'); } }
dojo.connect(map, "onClick", function(evt) { map.graphics.clear(); var def = locator.locationToAddress(esri.geometry.webMercatorToGeographic(evt.mapPoint), 100); def.then(function(candidate){ if (candidate.address) { //this service returns geocoding results in geographic - convert to web mercator to display on map var location = esri.geometry.geographicToWebMercator(candidate.location); var graphic = new esri.Graphic(location, symbol, candidate.address, infoTemplate); map.graphics.add(graphic); map.infoWindow.setTitle(graphic.getTitle()); map.infoWindow.setContent(graphic.getContent()); //display the info window with the address information var screenPnt = map.toScreen(location); map.infoWindow.resize(200,100); map.infoWindow.show(screenPnt,map.getInfoWindowAnchor(screenPnt)); } else{ //no address found console.log("No address found for this location"); } }); });
dojo.connect(map, "onClick", function(evt) { map.graphics.clear(); var def = locator.locationToAddress(esri.geometry.webMercatorToGeographic(evt.mapPoint), 100); def.then(function(candidate){ if (candidate.address) { //this service returns geocoding results in geographic - convert to web mercator to display on map var location = esri.geometry.geographicToWebMercator(candidate.location); var graphic = new esri.Graphic(location, symbol, candidate.address, infoTemplate); map.graphics.add(graphic); map.infoWindow.setTitle(graphic.getTitle()); map.infoWindow.setContent(graphic.getContent()); //display the info window with the address information var screenPnt = map.toScreen(location); map.infoWindow.resize(200,100); map.infoWindow.show(screenPnt,map.getInfoWindowAnchor(screenPnt)); } else{ //no address found console.log("No address found for this location"); } }, function(error){ console.log("error: " + error.message); }); });
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.