Giter Site home page Giter Site logo

Comments (1)

prasathfibonalabs avatar prasathfibonalabs commented on May 26, 2024

Found one the solution, Any other suggested solution,

<script lang="ts">
  import { onMount } from "svelte";
  import * as THREE from "three";

  import ThreeGlobe from "globe.gl";

  import countries from "../../assets/custom.geo.json";

  let globeElem: HTMLElement;

  let map = {
    coordinates: [
      {
        text: "IND",
        size: 1.0,
        country: "India",
        city: "Chennai",
        lat: "13.089869",
        lng: "80.245901",
      },
    ],
  };

  let Globe: any;

  onMount(() => {
    function init() {
      Globe = ThreeGlobe({
        waitForGlobeReady: true,
        animateIn: true,
      })
        .backgroundColor("#fff")
        .hexPolygonsData(countries.features)
        .hexPolygonResolution(3)
        .hexPolygonColor(() => "#c600e5")
        .hexPolygonMargin(0.7)
        .showAtmosphere(true)
        .atmosphereColor("#fff")
        .showAtmosphere(false)
        .atmosphereAltitude(0.25)
        .labelsData(map.coordinates)
        .labelColor(() => "#ffcb23")
        .labelDotRadius(0.3)
        .labelSize((e: any) => e.size)
        .labelText("city")
        .labelResolution(6)
        .labelAltitude(0.01)
        .pointsData(map.coordinates)
        .pointColor(() => "#c600e5")
        .pointAltitude(0.07)
        .pointLabel(
          () => `<div style="width:200px; height:100px; background:white;cursor:pointer;">
          <p>hello world</p>
          </div>`
        )(globeElem);

      const globeMaterial = Globe.globeMaterial();
      globeMaterial.color = new THREE.Color(0xffffff);
    }

    init();
  });

  const onLoadCoord = () => {
    const coordinatesCopy = [...map.coordinates];
   // update the Globe with existing points
    Globe.pointsData([
      coordinatesCopy,
      {
        text: "UAE",
        size: 1.0,
        country: "United Arab Emirates",
        city: "Dubai",
        lat: "23.214066",
        lng: "53.195262",
      },
    ]);
  };
</script>

<div class="globe" bind:this={globeElem} />

<div class="absolute top-0 left-5">
  <button class="p-5 bg-red-400" on:click={onLoadCoord}>
    Change Coordinates
  </button>
</div>

from globe.gl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.