location-search

Javascript lib to add location autocomplete to a input box

Usage no npm install needed!

<script type="module">
  import locationSearch from 'https://cdn.skypack.dev/location-search';
</script>

README

location-search

Javascript lib to add location autocomplete to a input box

Installation

npm i location-search

Usage

JavaScript

@import 'location-search';

HTML

<link rel="stylesheet" href="node_modules/@firstandthird/complete/lib/complete.css"/>
<div data-module="LocationSearch" class="module-complete">
  <input data-name="input" type="text" id="location-search" data-action="search" data-action-type="input" />
  <div data-name="resultsContainer"></div>
</div>

Attribution

Google requires anyone using the places api show attribution.

By default location-search uses ./img/light.png. This is the hidpi version so your css will need resize the image to 144px x 18px. There's also a img/dark.png available.

To change this, set the googleLogo option. This should be a path the browser can resolve. You can also set it to an empty string if you're going to display the logo elsewhere.