I'm a newbie in GIS world and recently built my own private osm tile server infrastructure that will be used in closed environment only and it works as a charm.

I tested the server inserting Leaflet code

var map = L.map('map').setView([48.1333,11.5667], 13);

L.tileLayer('http://{s}.mytileserver/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'

    .bindPopup('A pretty CSS3 popup.<br> Easily customizable.')

The marker exactly points to Munich and it works perfectly.

Next I tried to do almost the same by using Openlayers example:

var centerpos = [48.1333,11.5667]; // position in degrees
var newpos = ol.proj.transform(centerpos,'EPSG:4326','EPSG:900913');
var map = new ol.Map({
    view : new ol.View({
        projection : 'EPSG:900913', 
        center : newpos,
        zoom : 8.5,
        minZoom : 2,
        maxZoom : 12.5
    layers: [
        new ol.layer.Tile({
               source: new ol.source.OSM()
   target : 'map'

and the map created shows somewhere near Djibouti - Africa.

What have I done wrong with Openlayers3 example ?

Or did I do something wrong with installation of mapnik/postgis/osm ?

1 Answer 1


Try switching your lat/long positions. Leaflet and Openlayers have different approaches there...

leaflet uses lat-lon: http://leafletjs.com/reference.html#latlng openlayers uses lon-lat: http://dev.openlayers.org/docs/files/OpenLayers/BaseTypes/LonLat-js.html#OpenLayers.LonLat

  • Thanks a lot, I hope your answer will help other students.
    – StudentB
    Commented Sep 9, 2015 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.