Recently I started learning Openlayers 2x and I've been struggling for a while now with a GeoJSON and it's projections.

So, here is the deal;

I successfully added wms layers from ( http://geoportal.dgu.hr/podaci-i-servisi/svi-servisi-i-aplikacije/ ) with a projection HTRS96/TM (EPSG:3765) and then when I try to add vector layer it doesn't render it. Vector layer was created using QGIS software with a projection code:

"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::3765" }

Here is the OpenLayers code:

var map;

function init() {
    map = new OpenLayers.Map('map_element', {
        projection: 'EPSG:3765',
        maxExtent: new OpenLayers.Bounds(426906.034398, 5101783.64664,
        468058.881494, 5123976.6968),
        maxResolution: 'auto',
        units: 'm'              
    var wms = new OpenLayers.Layer.WMS(
        'DOF 1:5000',

    var wms2 = new OpenLayers.Layer.WMS(
        'TK 1:25 000',

        var wms3 = new OpenLayers.Layer.WMS(

    map.addControl(new OpenLayers.Control.LayerSwitcher({}));
    map.addControl(new OpenLayers.Control.MousePosition());

    var KZZ = new OpenLayers.Layer.Vector("KZZ", {
    protocol: new OpenLayers.Protocol.HTTP({
        url: "KZZ_JLS.json",
        format: new OpenLayers.Format.GeoJSON()
    strategies: [
        new OpenLayers.Strategy.Fixed()


And here is GeoJSON layer (fragment of it, whole file can be downloaded from this link https://dl.dropboxusercontent.com/u/126827789/KZZ_JLS.json):

"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::3765" } },                                                                         
"features": [
{ "type": "Feature", "properties": { "POVRINA": 27.027842695, "NAZIV": "Stubièke         Toplice" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 457191.01612696185, 5094147.6274271049 ], [ 457199.98992743361, 5094130.2420611409 ], [ 457231.34151837695, 5094112.0906051407 ], [ 457283.71295271069, 5094094.2316290718 ], [ 457310.09355065826,....

How can I render GeoJSON and add it to this file?

This problematic openlayers map can be viewed here htt()p://interaktiva.pregrada.hr/nc/--> to low reputation to add 2nd link on my post, pls remove ()

  • From a quick glance I would say it is projection related, you wms is in 4326 (lat/lon) and your JSON in projected meters, 3765. This is a fairly common issue and can be dealt with by setting a map and display projection and using transform on your JSON to convert it. I am afraid I don't have time to give you a working example, but if you search for transform coordinates in OpenLayers you should find something. Nov 27, 2014 at 6:32
  • Hmm, it says in WMS specification that original projection is EPSG:3765, (i'm referring to WMS that's in the posted map) same as JSON. Nevertheless, thank you for your kindness and time, I ll look into transforming coordinates and try to figure it out from there.
    – Svinjica
    Nov 27, 2014 at 6:44
  • Oh, sorry, my Serbo-Croat is a bit rusty :-) If they are the same projection, then there is a different problem. Nov 27, 2014 at 7:00
  • No problem :) I' ll cruise google for solution, maybe I'll find something useful. Thank you once again!
    – Svinjica
    Nov 27, 2014 at 7:27
  • If you put up a working example in jsfiddle, it might help also. Nov 27, 2014 at 8:08

1 Answer 1


The final answer is: your vector data is out of range. There were two problems with your map.

The first was, that your dataset contains three coordinate for every point, while OpenLayers 2 can only handle two. To fix this, you have to include an ignoreExtraDims parameter to your format object:

format: new OpenLayers.Format.GeoJSON({
    ignoreExtraDims: true

The second problem is, that your data is in the wrong place. Your WMS layers range roughly from 430.000 m to 480.000 m in X axis, and from 5.100.000 m to 5.130.000 m in Y axis. Your data, however ranges from 5.546.000 m to 5.597.000 m in X axis, while the Y range is correct. You have to shift your data to the correct place prior to visualizing.

  • Thx, I ll look into that as soon as possible. To be fair, I do have one question regarding third coordinate point. I looked it up at my GeoJSON file and I see only two coordinate 457191.01612696185, 5094147.6274271049 for every point
    – Svinjica
    Dec 2, 2014 at 6:56
  • You have to look a little bit closer, it is 5573986.9868397331, 5093902.9130302276, 0.0. Dec 2, 2014 at 8:33
  • Thx, I've missed it. Good job!
    – Svinjica
    Dec 2, 2014 at 8:59
  • Hmm, I'm afraid that I don't understand the second problem. When I add layers in QGIS (vector and wms) they overlap perfectly (added layers have same EPSG code 3765) and when I convert from .shp to .geojson and try to add that same vector layer it doesn't render it.
    – Svinjica
    Dec 2, 2014 at 9:22
  • 1
    It works now, don't know how but it works. Apparently problem was in ignoreExtraDims: true and size of geoJSON file, it needed some time to render it! Thank you guys!
    – Svinjica
    Dec 2, 2014 at 20:23

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.