let num = '1234';
console.log( `${ '${num}' }`);
bing map 지도 api
https://samples.bingmapsportal.com/?sample=
컨트롤러
String아니고 ResponseEntity라도 됨
@ResponseBody 없어도될지도..
@RequestMapping("/GetBingMapsKey.do")
@ResponseBody
public String getBingMapsKey() {
String bingMapsKey =key;
// 키가 있는 경우 텍스트/플레인 형식으로 응답
// return ResponseEntity.status(HttpStatus.OK).body(bingMapsKey);
// return ResponseEntity.ok().body(bingMapsKey);
return bingMapsKey;
}
jsp
<body>
<div id="myMap" style="position:relative;width:100%; width:350px;height:350px;background-color:gray"></div>
<script>
// Dynamic load the Bing Maps Key and Script
// Get your own Bing Maps key at https://www.microsoft.com/maps
let script = document.createElement("script");
let bingKey; // 변수 선언
(async () => {
bingKey = await fetch("http://localhost:8080/GetBingMapsKey.do").then(r => r.text());
bingKey = bingKey.replace(/"/g, "");
script.setAttribute("src", `https://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=${'${bingKey}'}`);
document.body.appendChild(script);
})();
</script>
</body>
bingKey로 불러온 부분이 ""때문에 먹히지 않아서 replace했음
jsp의 경우 백틱이 그냥 먹히지 않아서 ${ '${num}' }
이렇게 썼어야 했다...
🍆🍆....