Comments (7)
The results vary slightly, depending whether it is a predefined result or a Google Maps API result.
A predefined result looks like this:
{
"label": "Rio",
"placeId": "Rio",
"location": {
"lat": -22.066452,
"lng": -42.9232368
}
}
A Google Maps result looks like this:
{
"label": "Rio de Janeiro, Brazil",
"placeId": "ChIJw4riypQYmAAR0IMFwRrDSQM",
"location": {
"lat": -22.9068467,
"lng": -43.17289649999998
}
}
So the only difference is the placeID
. It is either the predefined one or the Google Maps one. Would you prefer to get the complete Google Maps result just like in the geocomplete plugin (which is by us, too ;) )? Also, not sure how to handle the placeId
. Return as null when not a Google Maps result?
You can check the results by opening the console and selecting results.
from react-geosuggest.
Ahhh, that makes a lot of sense now! I didn't realize the geocomplete and places API's were separate.
From the readme I thought it was supposed to fetch the places data too, not just the long/lat.
If I used this repo and had the ID or Long/Lat, would i then make an additional call to Google Places to get the full street_address, country, administrative_area_level_1, etc...data?
Basically i'm dropping my old templating language for React and the last thing stopping me is to replace the GeoComplete so that I can search for an address, click it, and autofill some form fields as needed. (Actually using Geocomplete after React's render may work out of the box since I still have jQuery.. haven't tried yet).
from react-geosuggest.
Just checked. First there is the autocomplete request to the places API. That returns something like this:
[
{
"description":"NYC, NY, United States",
"id":"7eae6a016a9c6f58e2044573fb8f14227b6e1f96",
"matched_substrings":[
{"length":3, "offset":0}
],
"place_id":"ChIJOwg_06VPwokRYv534QaPC8g",
"reference":"CmRYAAAAmsOZZgKoe5We5NX8Wfi0mzv9F3n2FqRMxMlOyna0dFW_QYXRI5u8gymVeR6xE8dfAmmUI3eDitA590MQs7G26Nl4z2NdA3amkdxL4UjgE-Sfms0wYXNbb_AdP9gMpCmlEhD4NqvTIcFJp27tAfvMCCzQGhTJ7dbZPhDw9ZvR4gaVEYpNzmPJYA",
"terms":[
{"offset":0, "value":"NYC"},
{"offset":5, "value":"NY"},
{"offset":9, "value":"United States"}
],
"types":[
"locality",
"political",
"geocode"
]
},
β¦
]
As there is no location data in that response, when selecting a suggestion later, there is a geocoding request. That geocoding request returns all the information you mentioned. Currently it gets filtered and only the location is returned.
I could add all the other data, too. Would keep the .location
, too for not breaking. The complete Google Geocoding response data could be added at .gmaps
. It would only be present when a geocoding was necessary. For presets this wonβt apply when initialized with a location. What do you think?
from react-geosuggest.
Complete places data is now available and documented: https://github.com/ubilabs/react-geosuggest#onsuggestselect
Thanks for reporting! Hope this helps in converting your app.
from react-geosuggest.
P.S.: Released as 1.2.0
.
from react-geosuggest.
Hey thanks @ro-ka !! π»
Keeping the location is ideal too since I can save that data to Mongo and use their Geospatial query when needed!
from react-geosuggest.
Great to hear! π
from react-geosuggest.
Related Issues (20)
- Billing issues HOT 3
- Expose TypeScript type definitions
- Warning: Prop `aria-owns` did not match. HOT 1
- selectSuggest doesn't trigger onSelectSuggests HOT 3
- Inconsitent suggest.gmaps property received in onSuggestSelect HOT 2
- Test `react-geosuggest` with puppeteer HOT 1
- utc_offset is deprecated as of November 2019 and will beturned off in November 2020. Use utc_offset_minutes instead. HOT 3
- How to allow current location ? and get address based on current location coordinates ? HOT 1
- ul role=listbox should define an aria-label or aria-labelledby HOT 2
- Support React 17 HOT 2
- Selected suggestion didn't apply properly, when searching in Argentina region HOT 1
- Type is invalid - expected a string or a class/function (for composite components) but got: undefined. Check the render method of `Input`. HOT 7
- Google maps API was not found in the page. HOT 2
- Handle the errors returned by the geocoder API
- Label "for" and input "id" do not match
- 'Avnei Hefetz' is an israli settlement city which is not coming in country 'IL' suggestions whereas 'Einav' is also an israli settlement city which is coming in country 'IL' suggestions. HOT 1
- How to detach geocomplete event?
- Using bounds not filtering suggests HOT 1
- Bounds, location, and radius are deprecated
- Support and document loading Maps API via Bootstrap Loader
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-geosuggest.