Wednesday, May 23, 2012

Adding a Google Map marker with Javascript from within <body>

I am trying to add a marker from within the tags and not between the tags. My map is created (succesfully) into the head.Same for markers IF i put the code within .



Problem is that i am using a CMS and need tags to be related pages.



The code below is within the usual tags.



<% control ChildrenOf(montreal) %>
<img ..... (this is the Google Icon whose number is called via $NoOfMarker texfield)
$NameOfVendor
. . .

<script type="application/javascript">
<!-- PROBLEM IS HERE -->
<!-- I want to add a marker specific to that child page using $Latitude and $Longitude textfields in the CMS (this works i checked) -->

marqueurX=new google.maps.LatLng($Latitude, $Longitude);
// go get $Latitude and $Longitude of the child page
myMarkerX = new google.maps.Marker({
position: marqueurX,
map: map,
title: '$Nom',
clickable: true,
icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld={$NoOfMarker}|bebe00|000000',
shadow: ombre
});

<!--
this code if placed into the <head> of the mother page, is working
but once placed inside <% control ... %> (or outside or out of <head>
this code does nothing - No errors, no markers either
i suspect a SCOPE or CLOSURE issues
-->
</script>
<% end_control %>


Thanks!





No comments:

Post a Comment