0

Trying to understand how to capture and store address in React.

I would like to achieve autocomplete functionality, so that user wouldn't be able to enter some scribbled address, instead user would start typing and then choose an address.

Ideally this address Component would return coordinates to save in MongoDB.

At the moment I am trying to figure out if Google is the right way to go, as there has been major pricing changes and I've heard that it's crazy expensive.

Conversely with the Mapbox I'm struggling big-time finding a working solution for this.

The needs are quite simple and as follows:

1 - capture accurate address of a location in a AddLocationComponent, store it in MongoDB

2 - display a pin of the location on a map within a SinglePostComponent

Ideally another Component with a map of multiple locations near by would be an option.

Could someone please share some wisdom in regards what services/technologies/methods to use to solve this?

Many thanks in advance!

Community
  • 1
  • 1
Scott Agirs
  • 599
  • 6
  • 14

1 Answers1

0

For Capturing the address first you need to get the latitude , longitude using geocodeLatLng(geocoder, map, infowindow); and then for formatted address i.e to get the address as normal string you need to use infowindow.setContent(results[0].formatted_address); follow this for your result hope it helps refer link

pageNotfoUnd
  • 666
  • 10
  • 20