Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Markers with ZoomableGlobe #72

Open
maalej opened this issue Mar 9, 2018 · 10 comments
Open

Markers with ZoomableGlobe #72

maalej opened this issue Mar 9, 2018 · 10 comments

Comments

@maalej
Copy link

maalej commented Mar 9, 2018

Hello & Thank you for this library.
When I display markers on ZoomableGlobe, they don't disappear while rotating the globe.

@zimrick
Copy link
Contributor

zimrick commented Mar 11, 2018

Hi @maalej ,
Are you working off of the globe example? If you build a globe from scratch yourself using <ZoomableGlobe />, make sure to specify the hidden styles for the <Marker /> components.

...
<Marker
    key={...}
    marker={...}
    style={{
        hidden: { display: "none" },
    }}>
    <circle cx={0} cy={0} r={10} />
</Marker>
...

Let me know if this solves your problem.

@maalej
Copy link
Author

maalej commented Mar 12, 2018

@zimrick Thank you very much for your response. Your solution does resolve my problem. Thank you.
However is it possible to project the markers with the orthographic projection to avoid this strange display:
globe

@zimrick
Copy link
Contributor

zimrick commented Mar 13, 2018

Is this the behaviour you are looking for?

circles-globe

If you want that you will have to render out the circles using d3-geo and a second <Geographies /> component.

import { geoCircle } from "d3-geo"

const circles = [
  geoCircle().center([3.4,6.5]).radius(10)(),
  geoCircle().center([100.5,13.7]).radius(5)(),
  geoCircle().center([-99.1,19.4]).radius(3)(),
]

// ...

render() {
  return (
    <ComposableMap projection="orthographic">
      <ZoomableGlobe sensitivity={0.5}>
        <Graticule globe style={{ strokeWidth: 0.5, strokeDasharray: [0,0] }} />
        <Geographies geography="/static/world-110m.json" disableOptimization>
          {(geos, proj) =>
            geos.map((geo, i) =>
              <Geography
                key={geo.properties.ISO_A3 + i}
                geography={geo}
                projection={proj}
                style={{
                  default: { fill: "#DDD" },
                  hover: { fill: "#DDD" },
                  pressed: { fill: "#DDD" },
                }}
              />
          )}
        </Geographies>
        <Geographies geography={circles} disableOptimization>
          {(geos, proj) =>
            geos.map((geo, i) =>
              <Geography
                key={i}
                geography={geo}
                projection={proj}
                style={{
                  default: { fill: "#FF5722", stroke: "#FFF" },
                  hover: { fill: "#FF5722", stroke: "#FFF" },
                }}
              />
          )}
        </Geographies>
      </ZoomableGlobe>
    </ComposableMap>
  )
}

Hope this helps.

@3h50
Copy link

3h50 commented Nov 28, 2018

@zimrick Where did you get the json for that world map? Exactly what I am looking for, the one in the example has a lot of polygon data I'd like to dump for speed.

EDIT: Got it, just deleted all of the countries. A custom map maker would be awesome for his but would need to know what correlates first.

@zimrick
Copy link
Contributor

zimrick commented Nov 28, 2018

Note (in case it's relevant) you can use this tool: https://mapshaper.org/

You can simplify any map quite easily there and then export it back as topojson for use with react-simple-maps. I describe the process in more detail here:
https://hackernoon.com/how-to-convert-and-prepare-topojson-files-for-interactive-mapping-with-d3-499cf0ced5f

@blaisedev
Copy link

Is this the behaviour you are looking for?

circles-globe

If you want that you will have to render out the circles using d3-geo and a second <Geographies /> component.

import { geoCircle } from "d3-geo"

const circles = [
  geoCircle().center([3.4,6.5]).radius(10)(),
  geoCircle().center([100.5,13.7]).radius(5)(),
  geoCircle().center([-99.1,19.4]).radius(3)(),
]

// ...

render() {
  return (
    <ComposableMap projection="orthographic">
      <ZoomableGlobe sensitivity={0.5}>
        <Graticule globe style={{ strokeWidth: 0.5, strokeDasharray: [0,0] }} />
        <Geographies geography="/static/world-110m.json" disableOptimization>
          {(geos, proj) =>
            geos.map((geo, i) =>
              <Geography
                key={geo.properties.ISO_A3 + i}
                geography={geo}
                projection={proj}
                style={{
                  default: { fill: "#DDD" },
                  hover: { fill: "#DDD" },
                  pressed: { fill: "#DDD" },
                }}
              />
          )}
        </Geographies>
        <Geographies geography={circles} disableOptimization>
          {(geos, proj) =>
            geos.map((geo, i) =>
              <Geography
                key={i}
                geography={geo}
                projection={proj}
                style={{
                  default: { fill: "#FF5722", stroke: "#FFF" },
                  hover: { fill: "#FF5722", stroke: "#FFF" },
                }}
              />
          )}
        </Geographies>
      </ZoomableGlobe>
    </ComposableMap>
  )
}

Hope this helps.

Hi, is this functionality possible in the new version with ZoomableGroup?

@zimrick
Copy link
Contributor

zimrick commented Mar 28, 2020

Not at the moment. The goal is to implement a proper globe with pinch zoom, but that will require a bit more time.

@cabello
Copy link

cabello commented Jan 12, 2021

Hello 👋

Is zoomable globe component still available? I can't find it while searching the repository. I also can't find the commit that removed it, hence I am asking about it.

Thank you 🙏

@deepsea
Copy link

deepsea commented Sep 22, 2022

Hello 👋

Is zoomable globe component still available? I can't find it while searching the repository. I also can't find the commit that removed it, hence I am asking about it.

Thank you 🙏

I reverted to version "react-simple-maps": "0.11.1" and it is available there

@nunof-castro
Copy link

nunof-castro commented Feb 10, 2024

Hey 🙌

There's any solution to hide the markers on version 3.0.0?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants