MapBox GL JS: Get lat and long coordinates from string Address that is set through code

I am using Mapbox GL JS to show certain location marked on the map.
I need to set location through JavaScript code and I don’t know the lat and long coordinates, I only have an address in string form (example: "address, city, country" or some similar format).

I have searched a lot on the internet, but the only way that I have found for doing this in Mapbox GL JS is by using Geocoder input control, but I don’t want to input location through it, I want to set Address through code and then have it marked on map when the map loads.

Is it possible to do this in Mapbox GL without knowing lat and long coordinates? How can I do that?

Thanks in advance! Best regards!

106 thoughts on “MapBox GL JS: Get lat and long coordinates from string Address that is set through code”

  1. Its like you read my mind! You seem to know so much about this,
    like you wrote the book in it or something. I think that you can do with some
    pics to drive the message home a bit, but instead of that, this is excellent blog.
    A fantastic read. I’ll certainly be back.

    Reply
  2. Hey are using WordPress for your site platform? I’m new
    to the blog world but I’m trying to get
    started and set up my own. Do you need any html coding expertise to
    make your own blog? Any help would be really appreciated!

    Reply

Leave a Comment