2017-11-25 12 views
0

Google Static Maps API 링크를 pug (jade) 템플릿 내에서 동적으로 만들 수있는 방법이 있습니까? 예를 들어 Google Static Maps API 옥 동적 링크

,

img.img-responsive.img-rounded(src='http://maps.googleapis.com/maps/api/staticmap?center=52.241770, -0.900181&zoom=17&size=400x350&sensor=true&markers=52.241770, -0.900181&scale=2&key=API_KEY') 

작동하지만

img.img-responsive.img-rounded(src='http://maps.googleapis.com/maps/api/staticmap?center={location.coords.lng},{location.coords.lat}&zoom=17&size=400x350&sensor=true&markers={location.coords.lng},{location.coords.lat}&scale=2&key=API_KEY') 

하지 않습니다.

답변

1

따옴표 사용은 어떻게됩니까?

img.img-responsive.img-rounded(src="http://maps.googleapis.com/maps/api/staticmap?center=" + location.coords.lng + "," + location.coords.lat + "&zoom=17&size=400x350&sensor=true&markers=" + location.coords.lng + "," + location.coords.lat + "&scale=2&key=API_KEY") 
1

보십시오 template literal.

img.img-responsive.img-rounded(src=`http://maps.googleapis.com/maps/api/staticmap?center=${location.coords.lng},${location.coords.lat}&zoom=17&size=400x350&sensor=true&markers=${location.coords.lng},${location.coords.lat}&scale=2&key=API_KEY`)