I defined a simple block on my module, using the following code.
function visita_virtual_block_view($delta = '') {
switch ($delta) {
case 'mapa':
$path = drupal_get_path('module','visita_virtual');
drupal_add_js('https://maps.google.com/maps/api/js?sensor=false','external');
drupal_add_js($path.'/visitavirtual.js');
$block['subject'] = t('google maps');
$block['content'] = visita_virtual_mapa_content();
return $block;
}
}
That returns a simple div with an specific id, wich will allow me to alter it later through the usage of the google maps api. For that I defined my 'visitavirtual.js' file, and inside of it I declared the Drupal behavior. That function is supposed to get executed when the whole page is loaded, since it'as a wrapper of the JQuery ready function.
(function($){
Drupal.behaviours.visita_virtual = {
attach: function(context,settings) {
alert('Entered the init function');
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
}
};
})(JQuery);
However, that code is not executed; I can't even see the alert window. What am I doing wrong?