web - How to make a URL with javascript variable? -
i trying pass javascript variable url, there sort of syntax error within it.
function initmap() { var jsondata = { $tourarray } var map = new google.maps.map(document.getelementbyid('map'), { zoom: 4, center: { lat: jsondata.centerlat, lng: jsondata.centerlon, }, }) var kml = jsondata.kmlfile var src = 'http://www.example.com/kml/?= + kml' var kmllayer = new google.maps.kmllayer(src, { map: map, }) }
the variable var kml
kml file name stored on server within folder kml , trying access file in order add kml layer on google map.
the url syntax seems incorrect.
you missed it.
var src = "http://www.example.com/kml/?=" + kml;
if you're using es6, template literals makes cleaner.
var src = `http://www.example.com/kml/?=${kml}`
Comments
Post a Comment