Select to view content in your preferred language

Is there any viewer to search by both address and feature

469
3
01-08-2014 10:50 AM
JoseSanchez
Regular Contributor
Hi all

Is there any GIS Javacript viewer to search by both address and attributes of a feature

Thanks
0 Kudos
3 Replies
JianHuang
Occasional Contributor III
You can create a locator based on point of interests and publish it as a geocode service. JavaScript Geocoder Widget can have multiple geocode services.
Or, you can tweak the geocoder widget a little bit:
    //add feature key words to geocode widget search box
    dojo.connect(geocoderWidget, "onAutoComplete", function (e) {
      if (geocoderWidget.value.length < 4) {
        return;
      }
      array.forEach(layerList, function (layer) {
        if (layer.declaredClass === "esri.layers.FeatureLayer" && layer.visible === true) {
          var keyWordField = layer.displayField;

          var searchedFeatures = array.filter(layer.graphics, function (feature) {
            return feature.attributes[keyWordField] ? feature.attributes[keyWordField].toLowerCase().indexOf(geocoderWidget.value.toLowerCase()) > -1 : false;
          });
          var result;
          array.forEach(searchedFeatures, function (feature) {
            result = {
              feature: feature,
              extent: new Extent(feature.geometry.x - 1000, feature.geometry.y - 1000, feature.geometry.x + 1000, feature.geometry.y + 1000, feature.geometry.spatialReference),
              name: feature.attributes[keyWordField]
            };
            e.results.splice(0, 0, result);
          });
        }
      });
      if (e.results.length > 6) {
        e.results.splice(6, e.results.length - 6);
      }
    });

    dojo.connect(geocoderWidget, "onSelect", function (e) {
      var query = new Query();
      var fl = e.feature.getLayer();
      if (!fl) {
        return;
      }
      query.where = fl.displayField + "='" + e.name + "'";
      
      fl.queryFeatures(query, function (result) {
        var feature = result.features[0];
        //now you have the selected feature
      });
    });
0 Kudos
JoseSanchez
Regular Contributor
Hi

Can I create a "You can create a locator based on point of interests and publish it as a geocode service"  in ArcGIs online and then call it for an ArcGIs Online template?

Or should I create a Basic Viewer web application download the code and then customize it locally?

The easiest solution is to work in ArcGIS online for me.
0 Kudos
JianHuang
Occasional Contributor III
As far as I understand, you cannot publish your own locator through arcgis.com. You have to have an ArcGIS Server running on your machine.
You may want to ask the question on arcgis.com forum to get confirmed.
0 Kudos