I would like to add a custom search/geocoder widget to a cmv page, in addition to the geocoding widget that is already included with the source code. I have thought about modifying the existing geocoding widget to include my service, but am unsure of how to do that. I thought adding an additional search may be easier. i have a custom geocode service and have it working in a simple map, but I'm not sure how to incorporate this into my cmv page.

Where should the code go?

I'm also wondering what map I reference for my custom search.

Here's what I have that works in a simple map:

<!DOCTYPE html>
    <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>Geocoder Widget</title>
    <link rel="stylesheet" href="http://js.arcgis.com/3.11/esri/css/esri.css">
      html, body, #map {
      body {
        font-family:"Trebuchet MS";
      #searchPM {
        display: block;
        position: absolute;
        z-index: 2;
        top: 20px;
        right: 30px;

    <script src="http://js.arcgis.com/3.11/"></script>
      var map;
      var geocoder;
      var locatorUrl = "http://sv04esri:6080/arcgis/rest/services/transportation/sde_Postmile_Locator/GeocodeServer";
        "esri/map", "esri/dijit/Geocoder", "dojo/domReady!"
      ], function(
        Map, Geocoder
      ) {
        map = new Map("map",{
          basemap: "topo",
          center: [-122.39, 37.852], // lon, lat
          zoom: 13

        var myGeocoders = [{
          url: locatorUrl,
          name: "PostmileLocator"
        geocoder = new Geocoder({
          map: map,
          autoComplete: true,
          arcgisGeocoder: false,
          geocoders: myGeocoders,
          value: "ALA 84 10.2"
    <div id="searchPM"></div>
    <div id="map"></div>
  • 1
    Are you saying you would like to query data layers? If not, what are you "searching" for? Commented Oct 15, 2014 at 17:22
  • 1
    no it would be another geocode widget, querying against my geocode service
    – kflaw
    Commented Oct 15, 2014 at 17:49

2 Answers 2


You can send any of the options available for the ESRI's Geocoder dijit to the CMV geocoder widget since it is simply a wrapper around the ESRI dijit.

For your example of adding your own geocoders, your widget options in config/viewer.js would look something like this:

geocoder: {
    include: true,
    id: 'geocoder',
    type: 'domNode',
    path: 'gis/dijit/Geocoder',
    srcNodeRef: 'geocodeDijit',
    options: {
        map: true,
        mapRightClickMenu: true,
        geocoderOptions: {
            autoComplete: true,
            arcgisGeocoder: false,
            geocoderMenu: true,
            geocoders: [{
                url: locatorUrl1,
                name: "PostmileLocator"
            }, {
                url: locatorUrl2,
                name: "Locator 2"
            value: "ALA 84 10.2"

For additional details on all the various options that you can use, refer to the ArcGIS For Developers link I posted above.

  • 1
    thanks again for your help i will check out the documentation
    – kflaw
    Commented Oct 15, 2014 at 19:01

As @tmcgee stated above but also the Wiki for CMV has this information already. User input regarding the CMV wiki is encouraged so it can be edited for clarity as CMV continues to grow in popularity.


Glad to see you got it working! @tmcgee is always helpful and insightful...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.