ArcGIS Online Basic Viewer - Change default text (Place or Address) in the Search tool

3973
4
03-30-2015 08:28 AM
MarkoEinspieler1
Esri Contributor

Dear all,

is it possible to change in the ArcGIS Online Basic Viewer the default text (Place or Address) in the search tool (see attachemant)? I downloaded the template via GitHub, but have not found any passage in the *.js-files to change it. And is it possible to maximize the results, when typing in some search?

Thanks and best regards,

Marko

0 Kudos
4 Replies
OwenGeo
Esri Notable Contributor

Hi Marko - I've moved this question to ArcGIS Online Templates​ to better assist you (the Basic Viewer isn't one of the Story Map apps).

Owen Evans
Lead Product Engineer | StoryMaps
0 Kudos
KellyHutchins
Esri Frequent Contributor

Marko,

You need to specify placholder text in the main.js file. If you want to do it for the standard address locator you can add the following code at approximately line 870.

                            geocoder.placeholder = "Custom placeholder text goes here";

0 Kudos
MarkoEinspieler1
Esri Contributor

Hi Kelly!

First, thank you for the help! This goes well for the geocoder "Esri World Geocoder". But in my first request I forgot to say, that the search happened in a "searchable layer". So I thing I have to configure the "Add search layers..." section. But I do not really know how an where... Could you please assist me?

Thanks,

Marko

0 Kudos
KellyHutchins
Esri Frequent Contributor

For a configured search layer you'll need to add a line that sets the placeholder in main.js around line 902. If you only have one search layer configured just add something like this:

                 source.placeholder = "My Custom Placeholder Text";

If you have more than one search layer you'll want to check the layer title or id first to ensure you get the correct placeholder text for the layer you are looking for. For the next release of ArcGIS Online we plan to provide an easier way for you to setup and configure the placeholders for search layers.

Another alternative would be to update the config.js file and add a new property called placeholder to the searchLayers section. Then you could check in main.js to see if you have a placeholder defined and then use that value.  So you'd update config.js like this;

    "searchLayers":[{
        "id": "myLayerId",
        "fields": ["parcelid"],
        "placeholder": "My Custom Placeholder"
    }],

Then update main.js as follows:

                      source.searchFields = layer.fields;
                            source.displayField = layer.fields[0];
                            if(layer.placeholder){
                                source.placeholder = layer.placeholder;
                            }
0 Kudos