This question may be related to a resolved thread.
I’m trying to add EE tags to a javascript file. The javascript file is setup as an EE template, and it’s type is set to “javascript”. I’m embedding the javascript template in the footer template, using this code:
{embed="includes/map-api-projects"}... where the template group is “includes” and the javascript template is “map-api-projects”.
When I load the page & view the source, the EE tags are being displaying exactly as they are written in the javascript. They are not inserting the information from the custom fields.
I’ve tried adding
$conf['protect_javascript'] = 'y';and
$conf['protect_javascript'] = 'n';to the config file. Neither have worked.
Here is my javascript code. Please note, I am opening & closing it with the standard script tags, but I don’t think the forum will allow that to show.
You’ll see the {page_projects} tag. I’m trying to repeat that block of code for every project entry in EE. So each time I add a new project entry, the custom fields inside this tag will be used and another marker will be created.
So here is what’s inside the script tags:
var map = null;
function initialize() {
var myOptions = {
zoom: 4,
center: new google.maps.LatLng(39.828175,-98.5795),
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDefaultUI: true,
navigationControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
},
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR
},
scaleControl: true,
scaleControlOptions: {
position: google.maps.ControlPosition.BOTTOM_LEFT
}
};
map = new google.maps.Map(document.getElementById("googlemap"),
myOptions);
google.maps.event.addListener(map, 'click', function() {
infowindow.close();
});
// Create location points & add markers to the map
{page_projects}
var point = new google.maps.LatLng({project_coordinate_lat},{project_coordinate_lng});
var marker = createMarker(point,'<h1>{if project_short_title}{project_short_title}{if:else}{title}{/if}<\/h1>{project_summary}<\/p><a href="{page_url}" title="View project ยป">View project »<\/a>')
{/page_projects}
} // end initialize
// Set default size of infowindow
var infowindow = new google.maps.InfoWindow(
{
size: new google.maps.Size(150,50)
});
// Create custom marker image
var image = new google.maps.MarkerImage('/img/icon/googlemap-marker.png',
// This marker is 20 pixels wide by 32 pixels tall.
new google.maps.Size(26, 26),
// The origin for this image is 0,0.
new google.maps.Point(0,0),
// The anchor for this image is 13,26.
new google.maps.Point(13, 26));
// Display markers & infowindows on the map
function createMarker(latlng, html) {
var contentString = html;
var marker = new google.maps.Marker({
position: latlng,
map: map,
icon: image,
zIndex: Math.round(latlng.lat()*-100000)<<5
});
// Open infowindows on click event
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(contentString);
infowindow.open(map,marker);
});
} // end function createMarker