Zvi
Zvi

Reputation: 627

HERE API Autocomplete - Paste an address isn't found. Only typing

I'm using the autocomplete API of HERE API. When I paste some address: "4141 Pingree Rd, Howell, MI 48843, United States", it finds nothing. But, if I'm typing that address, it is found.

Why if I paste an address it can't find anything? only by typing?

Here's the https request (without the app_code & app_id): https://autocomplete.geocoder.api.here.com/6.2/suggest.json?maxresults=5&country=USA&language=en-US&jsonattributes=1&query=4141%20Pingree%20Rd%2C%20Howell%2C%20MI%C2%A048843%2C%20United%20States&beginHighlight=%3Cmark%3E&endHighlight=%3C%2Fmark%3E&jsoncallback=__jsonp1_

Thanks.

Upvotes: 1

Views: 125

Answers (2)

Michel
Michel

Reputation: 28349

The issue is hard to see as it comes from a non-breaking space character (%C2%A0) added between the state 2-letter alpha code (MI in the example) and the postal code (48843).

With a regular space you would see the state code MI followed by %20 instead of %C2%A0.

With the non-breaking space, the API does not find the address. However it finds it with a regular space. Therefore, you need to do some additional string cleanup before sending it to the API, for example by chaining .replace(/\s/g, ' ') on the copied string.

Upvotes: 1

DFx
DFx

Reputation: 239

Perhaps you can use a workaround by detecting the paste in JavaScript and then trigger a "keydown" event on the input to make it bring up the results.

Some ideas:

Detect paste in input box

Trigger a keypress/keydown/keyup event in JS/jQuery?

Upvotes: 0

Related Questions