Closed zhg-kj closed 4 years ago
Hello, I am trying to use your geocoder in a for loop to loop over an array of markers in order to covert addresses to latitudes and longitudes on React. When I try to do this however, I receive the title error and the react app points towards this:
const temp = await geocoder.geocode(markers[i].address)
I am not completely sure what that means, to me it seems like it does not recognize geocode as a function?
Here is the rest of the related code:
const NodeGeocoder = require('node-geocoder'); const options = { provider: 'google', apiKey: key }; const geocoder = NodeGeocoder(options); //unrelated code inbetween let markers = [ { name: "Costco Wholesale", address: "9151 Bridgeport Rd, Richmond, BC V6X 3L9", position: { lat: 49.166590, lng: -123.133569 }, placeID: 'ChIJWc2NzuF0hlQRDu0NNhdQCjM' } ]; //Unrelated code inbetween async findLatLong(){ for(let i = 0; i < markers.length; i++){ const temp = await geocoder.geocode(markers[i].address) markers[i].position.lat = temp.latitude; markers[i].position.lng = temp.longitude; } }
I apologize if it is a stupid mistake, I am still a JS noob, but I have definitely given it my best shot before posting here :/
TIA!
Changed it so that I am using the geocoder in my backend. Works like a charm.
Hello, I am trying to use your geocoder in a for loop to loop over an array of markers in order to covert addresses to latitudes and longitudes on React. When I try to do this however, I receive the title error and the react app points towards this:
I am not completely sure what that means, to me it seems like it does not recognize geocode as a function?
Here is the rest of the related code:
I apologize if it is a stupid mistake, I am still a JS noob, but I have definitely given it my best shot before posting here :/
TIA!