javascript - Pass a variable to a static google image map -


i have variable store address on it. want pass google map static api:

like this

adr = comp.adress;  console.log(adr);// 28, rue armand carrel 
<img src="https://maps.googleapis.com/maps/api/staticmap?center={adr}&amp;size=600x300" alt="exemple" /> 

i don't value of adr wrong code ?

spaces handle

 "addr": "\n                \n                28, rue armand carrel \n              ", 

thank

what doing in yours reading {adr} part of string.

assuming above in react/es6/es2015.

you need concatenate string:

<img src={"https://maps.googleapis.com/maps/api/staticmap?center=" + adr + "&amp;size=600x300"} alt="exemple" />` 

or can use template literals:

<img src={`https://maps.googleapis.com/maps/api/staticmap?center=${adr}&amp;size=600x300`} alt="exemple" />` 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -