// add a graphics layer for geocoding results map.addLayer(new esri.layers.GraphicsLayer({ id: "results" })); // create the geocoder geocoder = new esri.dijit.Geocoder({ autoNavigate: false, // do not zoom to best result maxLocations: 20, // increase number of results returned map: map, arcgisGeocoder: { url: "http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer", name: "Esri World Geocoder", placeholder: "Find a place", sourceCountry: "USA" // limit search to the United States } }, "search"); geocoder.startup(); var symbol = new esri.symbol.PictureMarkerSymbol({ "angle":0, "xoffset":0, "yoffset":10, "type":"esriPMS", "url":"http://static.arcgis.com/images/Symbols/Shapes/BluePin1LargeB.png", "contentType":"image/png", "width":24, "height":24 }); dojo.connect(geocoder, "onFindResults", function(response) { var l = map.getLayer("results"); l.clear(); map.infoWindow.hide(); dojo.forEach(response.results, function(r) { r.feature.setSymbol(symbol); l.add(r.feature); }); });
// add graphics layer for result mainMap.addLayer(new GraphicsLayer({ id: "results" })); // create geocoder var geocoder = new Geocoder({ map: mainMap, autoComplete: true, arcgisGeocoder: { suffix: " Long Beach, CA", name: "Esri World Geocoder", placeholder: "find address within Long Beach" }, }, "addressFindDIV"); // name of the div it is referring to geocoder.startup(); // create new PictureMarkerSymbol object using a JSON object var symbol = new PictureMarkerSymbol({ "angle":0, "xoffset":0, "yoffset":10, "type":"esriPMS", "url":"http://static.arcgis.com/images/Symbols/Shapes/BluePin1LargeB.png", "contentType":"image/png", "width":24, "height":24 }); geocoder.on("find-results", function(response){ var l = mainMap.getLayer("results"); l.clear(); mainMap.infoWindow.hide(); array.forEach(response.results, function(r) { r.feature.setSymbol(symbol); l.add(r.feature); }); });
dojo.forEach(response.results, function(r) {
array.forEach(response.results, function(r) {
geocoder.on("find-results", function(response){ var l = mainMap.getLayer("results"); l.clear(); mainMap.infoWindow.hide(); for(var counter=0;counter>response.results.length;counter++){ function(r) { r.feature.setSymbol(symbol); l.add(r.feature); } } });
Thank you very much. I gave that a try, but I am not implementing it correctly, I guess. It will break my whole code:
geocoder.on("find-results", function(response){ var l = mainMap.getLayer("results"); l.clear(); mainMap.infoWindow.hide(); for(var counter=0;counter>response.results.length;counter++){ function(r) { r.feature.setSymbol(symbol); l.add(r.feature); } } });
Any suggestions? I'm fairly new to the API and JavaScript, so please point out the even most obvious stuff. Thanks
geocoder.on("find-results", function(response){ var l = mainMap.getLayer("results"); l.clear(); mainMap.infoWindow.hide(); for(var counter=0;counter>response.results.length;counter++){ //-- this is not required. Instead you will need to create an new object and loop through the //response.results which will be either an array or a JSON object depending on the response from the //geocoder. function(r) { r.feature.setSymbol(symbol); l.add(r.feature); } } });
Thank you very much. I gave that a try, but I am not implementing it correctly, I guess. It will break my whole code:
geocoder.on("find-results", function(response){ var l = mainMap.getLayer("results"); l.clear(); mainMap.infoWindow.hide(); for(var counter=0;counter>response.results.length;counter++){ function(r) { r.feature.setSymbol(symbol); l.add(r.feature); } } });
Any suggestions? I'm fairly new to the API and JavaScript, so please point out the even most obvious stuff. Thanks
geocoder.on("find-results", function(response){ var l = mainMap.getLayer("results"); l.clear(); mainMap.infoWindow.hide(); for(var counter=0;counter>response.results.length;counter++){ //-- this is not required. Instead you will need to create an new object and loop through the //response.results which will be either an array or a JSON object depending on the response from the //geocoder. function(r) { r.feature.setSymbol(symbol); l.add(r.feature); } } });
Thank you very much. I gave that a try, but I am not implementing it correctly, I guess. It will break my whole code:
geocoder.on("find-results", function(response){ var l = mainMap.getLayer("results"); l.clear(); mainMap.infoWindow.hide(); for(var counter=0;counter>response.results.length;counter++){ function(r) { r.feature.setSymbol(symbol); l.add(r.feature); } } });
Any suggestions? I'm fairly new to the API and JavaScript, so please point out the even most obvious stuff. Thanks
geocoder.on("find-results", function(response){ var l = mainMap.getLayer("results"); l.clear(); mainMap.infoWindow.hide(); for(var counter=0;counter>response.results.length;counter++){ //-- this function inside the for loop is not required. Instead you will need to create new object and loop through the response.results which will be either an array or a JSON object depending on the response from the geocoder. function(r) { r.feature.setSymbol(symbol); l.add(r.feature); } } });
Thank you very much. I gave that a try, but I am not implementing it correctly, I guess. It will break my whole code:geocoder.on("find-results", function(response){ var l = mainMap.getLayer("results"); l.clear(); mainMap.infoWindow.hide(); for(var counter=0;counter>response.results.length;counter++){ function(r) { r.feature.setSymbol(symbol); l.add(r.feature); } } });
Any suggestions? I'm fairly new to the API and JavaScript, so please point out the even most obvious stuff. Thanks 🙂
geocoder.on("find-results", function(response){ var l = mainMap.getLayer("results"); l.clear(); mainMap.infoWindow.hide(); for(var counter=0;counter>response.results.length;counter++){ //-- this is not required. Instead you will need to create an new object and loop through the //response.results which will be either an array or a JSON object depending on the response from the //geocoder. function(r) { r.feature.setSymbol(symbol); l.add(r.feature); } } });
the use of the on event was not setup correctly.
mapButton.on("click", changeMap);
geocoder.on("find-results",�?�
on(button, "click", clickHandler);