Drupal 7 giving Parse error: syntax error, unexpected T_STRING
Goal: To render a google map using geolocation.
I am trying to implement the below example on my site.
http://code.google.com/apis/maps/documentation/javascript/services.html#...
Working demo: http://code.google.com/apis/maps/documentation/javascript/examples/geoco...
I have implemented the code in my drupal_add_js() in hook_init() but I am getting an error
Parse error: syntax error, unexpected T_STRING in /home/vishal/public_html/dev/sites/all/modules/customvishal/customvishal.module on line 43
below is my code:
drupal_add_js('
var geocoder;
var map;
function initialize()
{
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
var address = "pune,india";
var latlng = new google.maps.LatLng();
geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': address}, function(results, status)
{
if (status == google.maps.GeocoderStatus.OK)
{
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker
({
map: map,
position: results[0].geometry.location
});
}
else
{
alert("Geocode was not successful for the following reason: " + status);
}
}
);
',
array('type' => 'inline', 'scope' => 'header', 'weight' => 5)
);
