Search code examples
javascriptgoogle-mapsgoogle-maps-api-3coordinatesgoogle-street-view

How to insert coordinates as variables into javascript?


I would like to ask a simple question... i have this command
getBase64FromImageUrl("https://maps.googleapis.com/maps/api/streetview?location=37.28,24.67&size=300x300&pitch=90")
in a Javascript scenario. How can i insert the coordinates into that, as variables? I tried to state before it: x=37.28 and y=24.67 and then to replace them with x and y, but the command doesn't understand it x and y as those coordinates. I want to do that, because the coordinates will be produced that moment and i won't be to able to know them before. Thank you in advance! :)


Solution

  • Do you mean like this! this uses ES6 notation template literals.

    let x= 37.28 ,y= 24.67
    let myString = `https://maps.googleapis.com/maps/api/streetview?location=${x},${y}&size=300x300&pitch=90`
    getBase64FromImageUrl(myString);