Select to view content in your preferred language

Troubles with searchWidget.on()

267
0
12-12-2022 11:25 AM
PauloCésarBecerraPachas
New Contributor

Hello everyone, I am new to using widgets and when using search with several layers and when performing a specific zoom in each one of these (layers of points and polygons) it happens that the zoom is carried out at the same scale (scale: 500000) without distinguishing neither the point nor the polygon; Due to this, when doing the search for the place (points layer) everything goes well, however when doing the search for the country (polygonal layer) the zoom is performed as if it were the points layer and I cannot see the entire searched country.

 

 

  const searchWidget = new Search({
    view: view,
    allPlaceholder: "Offices",
    includeDefaultSources: false,
    sources: [
      {
        layer: offices,
        searchFields: ["InS_ID"],
        displayField: "InS_ID",
        exactMatch: false,
        outFields: ["*"],
        name: "Offices",
        placeholder: "example: INS#739",
        zoomScale: 500000
      },
      {
        layer: warehouses,
        searchFields: ["InS_ID"],
        displayField: "InS_ID",
        exactMatch: false,
        outFields: ["*"],
        name: "Warehouses",
        placeholder: "example: INS#277",
        zoomScale: 500000
      },      
      {
        layer: Countries,
        searchFields: ["COUNTRYAFF"],
        displayField: "COUNTRYAFF",
        exactMatch: false,
        outFields: ["*"],
        name: "Countries",
        placeholder: "example: Colombia",
        zoomScale: 1800000
      },
      {
        name: "ArcGIS World Geocoding Service",
        placeholder: "example: Nuuk, GRL",
        apiKey: "AAPK0ff1435fcfc94370a5e13e33f38bb0d2bXmccuDrhStP1yGMkJLIiSMsyUnJVE8JxEgkin0sIr1r7WrTL3dUxvR3i6LPjVd7",
        singleLineFieldName: "SingleLine",
        url: "https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer"
      }
    ]
  });

  searchWidget.on("select-result",
  function(){
      view.goTo({
        scale: zoomScale
      });
  });
0 Kudos
0 Replies