TransWikia.com

OSM Buildings - problem adding .obj file

Geographic Information Systems Asked by minisaurus on August 4, 2021

I’ve started playing with OSM Buildings, have modified an example.

I am unable to display a custom object I’m downloading using map.addOBJ

The script downloads the .obj and .mtl files from the webserver.

In the console, I see a "Uncaught TypeError: Cannot read property ‘color’ of undefined
at processOBJ (blob:null/afde6e25-7336-40a4-8805-46fbdeb82782:1)
at XMLHttpRequest.r.onreadystatechange"

Here’s the code:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <style>
    html, body {
      margin: 0;
      padding: 0;
      width: 100%;
      height: 100%;
    }
    #map {
      width: 100%;
      height: 100%;
    }
  </style>
  <link href="https://cdn.osmbuildings.org/4.0.0/OSMBuildings.css" rel="stylesheet">
  <script src="https://cdn.osmbuildings.org/4.0.0/OSMBuildings.js"></script>
</head>
<body>
  <div id="map"></div>
  <script>
  var osmb = new OSMBuildings({
    container: 'map',
    position: { latitude: 57.758939, longitude: 11.963272  },
    zoom: 16,
    minZoom: 15,
    maxZoom: 22,
    tilt: 40,
    rotation: 300,
    effects: ['shadows'],
    state: true, // stores map position/rotation in url
    attribution: '...'
  });

  osmb.addMapTiles(
    'https://tile-a.openstreetmap.fr/hot/{z}/{x}/{y}.png',
    {
      attribution: '..'
    }
  );

  osmb.addOBJ('https://treemapp.com/ar/lowpolytree.obj', 
    { latitude: 57.758455, longitude: 11.962948 }, 
    { id:'marker', color: 'green', scale: 20, /* rotation:50 altitude: 0, */ });
  </script>
</body>
</html>

What to do?

One Answer

I updated the version of OSM buildings to 4.1.1, and now the object is displayed, and there is no error :)

<link href="https://cdn.osmbuildings.org/4.1.1/OSMBuildings.css" rel="stylesheet"> <script src="https://cdn.osmbuildings.org/4.0.0/OSMBuildings.js"></script>

Answered by minisaurus on August 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP