Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I wan't to use setCenter method in a javascript to interact with a listbox.
At first this code is working fine :
var ol = jQuery('.openlayers-map').data('openlayers');//assuming there is just one map on the page
ol.openlayers.zoomTo(9);
But this code isn't working :
var ol = jQuery('.openlayers-map').data('openlayers');//assuming there is just one map on the page
var lonLat = new OpenLayers.LonLat(47.678334,-2.590485).transform(new OpenLayers.Projection("EPSG:4326"), ol.openlayers.getProjectionObject());
ol.openlayers.setCenter(lonLat, 11);
if you search 47.678334,-2.590485 in google maps, you arrive somwhere in the west of france, but my openlayer map is showing a point somewhere near Somalia ;)
Thanks for helping !
Comments
Comment #1
cyprien2 CreditAttribution: cyprien2 commentedMy fault, it was not :
var lonLat = new OpenLayers.LonLat(47.678334,-2.590485).transform(new OpenLayers.Projection("EPSG:4326"), ol.openlayers.getProjectionObject());
but
var lonLat = new OpenLayers.LonLat(-2.590485, 47.678334).transform(new OpenLayers.Projection("EPSG:4326"), ol.openlayers.getProjectionObject());
i've inverted Lontitude and Latitude :(
Comment #2
cyprien2 CreditAttribution: cyprien2 commented