Openlayers OSM always set on (long/lat) (0/0)

this is my code

map = new OpenLayers.Map("map");    
// I tried several projections here, all lead to the same result
var proj = new OpenLayers.Projection("WGS84");
var point = new OpenLayers.LonLat(position.coords.latitude,position.coords.longitude);
point.transform(proj, map.getProjectionObject());

// the output of this shows the correct coordinates
console.log("latitude: "+position.coords.latitude+"  long "+position.coords.longitude);

var mapnik = new OpenLayers.Layer.OSM();

It always shows the map centered on coordinate (0/0) wich is somewhere in the atlantic ocean. Where is my error? I cant solve this and find nothing on google. Please help.

This, however, works.

map = new OpenLayers.Map( 'map');
layer = new OpenLayers.Layer.OSM( "Simple OSM Map");
  new OpenLayers.LonLat(position.coords.latitude,position.coords.longitude).transform(
  new OpenLayers.Projection("EPSG:4326"),
  ), 12


If you tried several projections and all lead to the same result that's probably because Proj4js is not correctly loaded (see

Check also this example: (coords re-projection from EPSG:4326)

Need Your Help

Single quotes in a variable

sql-server tsql

Any idea why this Select IN does not work when I hard code values in a variable?

Regex (a?)* not exponential?

regex theory pcre backtracking finite-automata

I am currently looking into the problem of regular expressions which can end up running in exponential time when matched against a certain input, for example both (a*)* and (a|a)* potentially exhibit

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.