How can I overlay the country shapes from this Leaflet example onto a WebGL Earth globe?

I've tried replacing geojson = L.geoJson(euCountries).addTo(map); with geojson = WE.geoJson(euCountries).addTo(earth);.

This produces: TypeError: WE.geoJson is not a function

I am adapting this code, importing the data and making the change listed above, to produce this:

    <script src="http://www.webglearth.com/v2/api.js"></script>
    <script type="text/javascript" src="https://leafletjs.com/examples/map-panes/eu-countries.js"></script>
      function initialize() {
        var earth = new WE.map('earth_div');

        var marker = WE.marker([51.5, -0.09]).addTo(earth);
        marker.bindPopup("<b>Hello world!</b><br>I am a popup.<br /><span style='font-size:10px;color:#999'>Tip: Another popup is hidden in Cairo..</span>", {maxWidth: 150, closeButton: true}).openPopup();

        var marker2 = WE.marker([30.058056, 31.228889]).addTo(earth);
        marker2.bindPopup("<b>Cairo</b><br>Yay, you found me!", {maxWidth: 120, closeButton: false});

        var markerCustom = WE.marker([50, -9], '/img/logo-webglearth-white-100.png', 100, 24).addTo(earth);

        geojson = WE.geoJson(euCountries).addTo(earth);

        earth.setView([51.505, 0], 3);
      html, body{padding: 0; margin: 0; background-color: black;}
      #earth_div{top: 0; right: 0; bottom: 0; left: 0; position: absolute !important;}
    <title>WebGL Earth API: Markers</title>
  <body onload="initialize()">
    <div id="earth_div"></div>
  • There is no such layer type as WE.geoJson in WebGL. If you look at the WebGL docs at sites.google.com/site/webglearth, you'll see that standard GeoJSON layers are not supported yet. – TomazicM Aug 8 at 9:47
  • Thanks for clarifying – zadrozny Aug 8 at 13:08

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.