OSMBuilding has a function which allows 3D json file be added to Leaflet as stated here. The question is how I can get the same format from GeoServer.

I have tried this


as stated here and here, I could get a Json output like this:


While I need sth like this as stated here

    "type": "FeatureCollection",
    "features": [{
    "type": "Feature",
    "geometry": {
    "type": "Polygon",
    "coordinates": [

    [174.749268, -36.853149],
    [174.751368, -36.854249],
    [174.752468 ,-36.855349],
    [174.753568 ,-36.856449 ],
    [174.749268, -36.853149]

    "properties": {
    "color": "rgb(255,200,150)",
    "height": 220

this means I do not need this


from Geoserver, but I do not know how I could get the right format.

  • 1
    The extra elements like "totalFeatures":1 should not make any trouble. What probably makes is that your feature type in GeoServer has linestrings while OSMBuilding wants polygons. Also your data has X,Y,Z coordinates while OSMBuilding wants only X,Y and height as an attribute. You must start by processing your source data.
    – user30184
    Oct 6 '17 at 6:16
  • Thank you @user30184, So you meant I need to write a piece of code to convert the Json output from geoserver to an appropriate format for Leaflet, right? Does not this processing create some extra delay and slow down the visualization? Is there any more efficient way, plugin, Oct 6 '17 at 9:11
  • I mean that if you need 2D polygons with height and color as attributes you'd better to save them as such into your database. Then GeoServer should create suitable GeoJSON for you out-of-the-box.
    – user30184
    Oct 6 '17 at 12:43
  • That is a good point, I will try that on Monday and keep you posted. thank you Oct 6 '17 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.