The "Drupal.behaviors" doesn't behave as "document.ready", if I use a document.ready I will have the correct map but if I do a Drupal.behaviors, there will be an error related to the openlayers library function which is not found :(
After check, the OpenLayers.js is loaded after my module js. Is it possible to make it load after another one ? I though adding a dependency on another module would make him load before the other one.
If I use a setTimeout it's working but it's not the best solution !
Do you have any idea how I can do that ?
Thank you guys
(function ($) {
Drupal.OL_lat_long = Drupal.OL_lat_long || {};
Drupal.behaviors.OL_lat_long = {
attach: function (context, settings) {
setTimeout(function(){
var map = $('#openlayers-map').data('openlayers').openlayers;
var pointLayer= map.layers[1];
console.log(pointLayer);
proj4326 = new OpenLayers.Projection("EPSG:4326");
proj900913 = new OpenLayers.Projection("EPSG:900913");
Drupal.OL_lat_long.dragPoint();
Drupal.OL_lat_long.actualizeLatLong();
Drupal.OL_lat_long.clickMap();
$('#redrawPoint').click(function(){
Drupal.OL_lat_long.redrawPointOnMap();
Drupal.OL_lat_long.actualizeLatLong();
});
},200);
// });
}
}
}(jQuery));