I need to dynamic the image path to my theme file within a javascript file. How would I go about this?
address.forEach(function(address){
var markerGeoCoder;
markerImage = {url: window.mr_variant == undefined ? 'img/mapmarker.png' : '../img/mapmarker.png', size: new google.maps.Size(50,50), scaledSize: new google.maps.Size(50,50)};
if(/(\-?\d+(\.\d+)?),\s*(\-?\d+(\.\d+)?)/.test(address) ){
var latlong = address.split(','),
marker = new google.maps.Marker({
position: { lat: 1*latlong[0], lng: 1*latlong[1] },
map: map,
icon: markerImage,
title: markerTitle,
optimised: false
});
}
I already tried this :
address.forEach(function(address){
var markerGeoCoder;
markerImage = {url: window.mr_variant == undefined ? '<?php the_field('img/mapmarker.png'); ?>' : '../img/mapmarker.png', size: new google.maps.Size(50,50), scaledSize: new google.maps.Size(50,50)};
if(/(\-?\d+(\.\d+)?),\s*(\-?\d+(\.\d+)?)/.test(address) ){
var latlong = address.split(','),
marker = new google.maps.Marker({
position: { lat: 1*latlong[0], lng: 1*latlong[1] },
map: map,
icon: markerImage,
title: markerTitle,
optimised: false
});
}
But it's not working.
<script></script>tag in a template, or in a .js file that you're enqueueing?