Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

273-remove-suggest-pad #274

Merged
merged 3 commits into from Jul 19, 2021
Merged

273-remove-suggest-pad #274

merged 3 commits into from Jul 19, 2021

Conversation

jwasilgeo
Copy link
Contributor

Alleviates different "/suggest" vs. "/findAddressCandidates" behavior when a searchBounds option is used, by removing the automatically applied bounds.pad(0.5) in the suggest within method.

Related to #273.

Try to search for "park bench cafe" as described in #273 in the JSBin example, and then try again in a local checkout of this PR with the code sample provided below.

local demo sample
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />
  <title>Geocoding control</title>
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />

  <link rel="stylesheet" href="../node_modules/leaflet/dist/leaflet.css" />
  <script src="../node_modules/leaflet/dist/leaflet-src.js"></script>

  <script src="../node_modules/esri-leaflet/dist/esri-leaflet-debug.js"></script>

  <link rel="stylesheet" href="../dist/esri-leaflet-geocoder.css" />
  <script src="../dist/esri-leaflet-geocoder-debug.js"></script>
  <style>
    body {
      margin: 0;
      padding: 0;
    }

    #map {
      position: absolute;
      top: 0;
      bottom: 0;
      right: 0;
      left: 0;
    }
  </style>
</head>

<body>

  <div id="map"></div>

  <script>
    var map = L.map('map').setView([40.91, -96.63], 4);

    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
      attribution: '&copy; <a href="https://osm.org/copyright">OpenStreetMap</a> contributors'
    }).addTo(map);

    const southWest = L.latLng(33.685131100831214, -117.98251451552146);
    const northEast = L.latLng(33.73448856010863, -117.91114531893689);
    const searchBounds = L.latLngBounds(southWest, northEast);

    var rectangle = L.rectangle(searchBounds).addTo(map);

    var searchControl = L.esri.Geocoding.geosearch({
      position: 'topright',
      placeholder: 'Enter an address or place e.g. 1 York St',
      useMapBounds: false,
      searchBounds: searchBounds,
      providers: [L.esri.Geocoding.arcgisOnlineProvider({
        apikey: 'ABC XYZ YOUR KEY',
      })]
    }).addTo(map);

    var results = L.layerGroup().addTo(map);

    searchControl.on('results', function (data) {
      results.clearLayers();
      for (var i = data.results.length - 1; i >= 0; i--) {
        results.addLayer(L.marker(data.results[i].latlng));
      }
    });
  </script>

</body>

</html>

Copy link
Contributor

@gavinr gavinr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot think of any reason that the Suggest should be padded but the findAddressCandidates should not, so it makes sense to me to remove this (what this PR is doing). So seems good to me 👍

@jwasilgeo jwasilgeo merged commit 33b2a7b into master Jul 19, 2021
@jwasilgeo jwasilgeo deleted the 273-remove-suggest-pad branch July 19, 2021 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants