google-maps-react icon indicating copy to clipboard operation
google-maps-react copied to clipboard

Language not working

Open Michael-Reich opened this issue 6 years ago • 5 comments

I tested it in the example and the language did not change at all.

export default GoogleApiWrapper({
  apiKey: "AIzaSyAyesbQMyKVVbBgKVi2g6VX7mop2z96jBo",
  v: "3.30",
  language: "ja"
})(MapContainer);

Link to codesandbox

Michael-Reich avatar Jun 20 '18 12:06 Michael-Reich

Are you using the npm package? Or just following the tutorial?

If you're following the tutorial, you must see this merge: https://github.com/fullstackreact/google-maps-react/pull/40/commits/e638ca84e874561321d4e6c01a058880d00d61da

If you're using the npm package, you need to put your api-key inside (). Example: apiKey: ("your-api-key")

AikoRamalho avatar Jun 20 '18 19:06 AikoRamalho

Still not working ...

Is it maybe because I use it with Redux?

const MapWrappedContainer = connect(
    (state) => (
        {
          content: state.contentReducer,
          center: state.locationReducer.center,
          lang: state.contentReducer.lang,
          country: state.contentReducer.country,
          routingData: state.contentReducer.routingData
        }
    ),

    (dispatch) => (
        {
          setLocationsShown: (ids) => dispatch(actions.setLocationsShown(ids)),
          setLocationsCenter: (ids) => dispatch(actions.setLocationsCenter(ids)),
          getRoutingData: (language) => dispatch(actions.getRoutingData(language))
        }
    )
)(MyMapContainer);

export default GoogleApiWrapper(
  (props) => ({
    apiKey: ('API_KEY'),
    language: 'fr'
  }
))(MapWrappedContainer);

Michael-Reich avatar Jun 21 '18 08:06 Michael-Reich

It seems like a problem with Redux, i've never worked with it, so I cant help you there... Sorry, hope you find the solution.

AikoRamalho avatar Jun 21 '18 18:06 AikoRamalho

I got it working, that the language chagnes, but not if I do it with this:

export default GoogleApiWrapper(
  (props) => ({
    apiKey: props.apiKey,
    language: props.lang
  })
)(MapComponent);

If I do it like this:

export default GoogleApiWrapper({
    apiKey: ('API_KEY'),
    language: 'de'
})(MapComponent);

it works

but even this does not work:

export default GoogleApiWrapper(
  (props) => ({
    apiKey: (API_KEY),
    language: 'de'
  })
)(Component);

Michael-Reich avatar Jul 16 '18 08:07 Michael-Reich

Anyone known how solve this issue? I saw that the problem is that the first time loads the google script https://maps.googleapis.com/maps/api/js?key=API_KEY&callback=loaderCB01612358397367&libraries=geometry,drawing,places&v=3&language=pt&onerror=ERROR_FUNCTION but then never change the language so it is loaded only the first time.

Thanks

lmbuffetti avatar Feb 03 '21 13:02 lmbuffetti