POST
|
Hi everybody, I've built a custom address locator and I want to create a web page using it. My goal is to have a page with the "search" space as with the search widget but i want the result of the request to be an array with all results (if needed) where it's possible to select which results to show on the map. I've tried starting with: Locator | API Reference | ArcGIS API for JavaScript 4.0 and this: Search Widget 3D | ArcGIS API for JavaScript 4.0 So it works but I don't have an array and only the first result of "Match_addr" is shown... If someone has already done this it would be very usefull or if somebody has an idea? Thanks a lot Guillaume Golay One example of working code (this one is using 3.17 API update but same thing with 4.0): <!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>Search widget using custom locator</title> <link rel="stylesheet" href="https://js.arcgis.com/3.17/esri/css/esri.css"> <style> html, body, #map { height: 100%; width: 100%; margin: 0; padding: 0; } body { background-color: #FFFFFF; overflow: hidden; font-family: "Trebuchet MS"; } #search { display: block; position: absolute; z-index: 2; top: 20px; left: 75px; } .arcgisSearch .searchGroup .searchInput { width: 15.625rem; } </style> <script src="https://js.arcgis.com/3.17/"></script> <script> require([ "esri/map", "esri/tasks/locator", "esri/dijit/Search", "esri/symbols/PictureMarkerSymbol", "esri/InfoTemplate", "dojo/domReady!" ], function (Map, Locator, Search, PictureMarkerSymbol, InfoTemplate){ var map; var locatorUrl = "http://s011656v.adacv.ad.etat-de-vaud.ch:6080/arcgis/rest/services/TEST/LOC_VD_GEOPORTAIL/GeocodeServer"; map = new Map("map", { basemap: "topo", center: [6.6, 46.5], // lon, lat zoom: 10 }); var search = new Search( { sources: [ { //Pass in the custom locator to the sources locator: new Locator(locatorUrl), singleLineFieldName: "SingleKey", outFields: ["*"], name: "VD_GEOPORTAIL", placeholder: "exemple: Place de la Riponne Lausanne 1005", highlightSymbol: new PictureMarkerSymbol("https://js.arcgis.com/3.17/esri/dijit/Search/images/search-pointer.png", 36, 36).setOffset(9, 18), //Create an InfoTemplate infoTemplate: new InfoTemplate("Match_addr", "${Match_addr}") } ], map: map, enableSearchingAll: false, autoComplete: true, value: "exemple: Place de la Riponne Lausanne 1005" }, "search"); search.startup(); }); </script> </head> <body> <div id="search"></div> <div id="map"></div> </body> </html>
... View more
08-09-2016
06:22 AM
|
0
|
1
|
1429
|
POST
|
Hi, Dropbox - locator_python Here's a copy of the folder. Thanks for helping me! (Just have to say to you that i solved my problem but i'm interesting about understanding why). My solution was: # Import arcpy module import arcpy # Local variables: INTER = "C:\\Users\\w2sohi\\Desktop\\test\\INTER" # Process: Recréer le localisateur d’adresses arcpy.RebuildAddressLocator_geocoding(INTER) So not calling the toolbox, and replace RebuildAddressLocator_box(INTER) with RebuildAddressLocator_geocoding(INTER)
... View more
06-24-2016
12:21 AM
|
0
|
2
|
620
|
POST
|
Dear Dan, I modified my script like this: # Import arcpy module import arcpy # Local variables: INTER = "C:\\Users\\w2sohi\\Desktop\\test\\INTER" # Process: Recréer le localisateur d’adresses arcpy.RebuildAddressLocator_geocoding(INTER) And now it works! The problem came from arcpy.ImportToolbox but I don't know exactly what was happenning. Thank you very much for your help Guillaume
... View more
06-23-2016
01:34 AM
|
0
|
0
|
620
|
POST
|
Thank you all for helping me! So, I've changed the paths, following Blake's advise, add an alias "box" to my toolbox "box.tbx", following Micah's advise. Now the code looks like this: # Import arcpy module import arcpy # Load required toolboxes arcpy.ImportToolbox(r"C:\Users\w2sohi\Desktop\test\box.tbx","box") # Local variables: INTER = "C:\\Users\\w2sohi\\Desktop\\test\\INTER" # Process: Recréer le localisateur d’adresses arcpy.RebuildAddressLocator_box(INTER) But, the error messages still remain the sames: Traceback (most recent call last): File "C:\Users\w2sohi\Desktop\test\recreer.py", line 13, in <module> arcpy.ImportToolbox(r"C:\Users\w2sohi\Desktop\test\box.tbx","box") File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\__init__.py", line 90, in ImportToolbox return import_toolbox(input_file, module_name) File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\toolbox_code.py", line 441, in import_toolbox mymodule = generate_toolbox_module(toolbox, None, False, False, False, module_name, use_alt_alias) File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\toolbox_code.py", line 399, in generate_toolbox_module use_alt_alias)) File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\toolbox_code.py", line 391, in <genexpr> code = u"\n".join(line if isinstance(line, unicode) File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\toolbox_code.py", line 311, in code_for_toolbox yield "__all__ = %r" % ([str(tool.name) for tool in toolbox.tools],) UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 3: ordinal not in range(128) Freddie and Dan, the name of the tool is: RebuildAddressLocator, Label is: Recréer le localisateur d'adresses (as I live in the french part of Switrzerland). So, in any case, I don't find any "è"... Is it possible that there's a problem with roots files as x86)\ArcGIS\Desktop10.1\arcpy\arcpy\toolbox_code.py or x86)\ArcGIS\Desktop10.1\arcpy\arcpy\__init__.py ? (as they are mentionned in the error messages) Also, I've tried to run the code with only: # Import arcpy module import arcpy # Load required toolboxes arcpy.ImportToolbox(r"C:\Users\w2sohi\Desktop\test\box.tbx","box") And also got the same error message. The problem seems to come from here...
... View more
06-22-2016
11:37 PM
|
0
|
2
|
844
|
POST
|
Hi, I've built a model with model builder. When I run it from model builder it works but now that i've exported it to python, it doesn't work... Here is my model: # Import arcpy module import arcpy # Load required toolboxes arcpy.ImportToolbox("C:/Users/w2sohi/Desktop/test/box.tbx","box") # Local variables: INTER = "C:\\Users\\w2sohi\\Desktop\\test\\INTER" # Process: Recréer le localisateur d’adresses arcpy.RebuildAddressLocator_box(INTER) It seems that there's a problem with: arcpy.ImportToolbox("C:/Users/w2sohi/Desktop/test/box.tbx","box") I have these error messages: Traceback (most recent call last): File "C:\Users\w2sohi\Desktop\test\recreer.py", line 13, in <module> arcpy.ImportToolbox("C:/Users/w2sohi/Desktop/test/box.tbx","box") File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\__init__.py", line 90, in ImportToolbox return import_toolbox(input_file, module_name) File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\toolbox_code.py", line 441, in import_toolbox mymodule = generate_toolbox_module(toolbox, None, False, False, False, module_name, use_alt_alias) File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\toolbox_code.py", line 399, in generate_toolbox_module use_alt_alias)) File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\toolbox_code.py", line 391, in <genexpr> code = u"\n".join(line if isinstance(line, unicode) File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\toolbox_code.py", line 311, in code_for_toolbox yield "__all__ = %r" % ([str(tool.name) for tool in toolbox.tools],) UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 3: ordinal not in range(128) Thank you very much! Guillaume
... View more
06-22-2016
08:33 AM
|
0
|
21
|
6232
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|