Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

How to display country names in Polygons? #57

Closed
jinzhe opened this issue Jul 2, 2021 · 5 comments
Closed

How to display country names in Polygons? #57

jinzhe opened this issue Jul 2, 2021 · 5 comments

Comments

@jinzhe
Copy link

jinzhe commented Jul 2, 2021

I want to display the country name in the polygon, but the api does not seem to have a relevant method.

@vasturiano
Copy link
Owner

@jinzhe you have polygonLabel if you'd like to display any content in the tooltip on polygon hover. If you'd like to add permanently visible labels you can use the labels layer to add a label to each polygon, potentially at the centroid of each polygon.

@jinzhe
Copy link
Author

jinzhe commented Jul 3, 2021

After using label, it can be displayed, but Chinese cannot be displayed. Can you tell me how to use labelTypeface?

Such as using this

https://www.wjceo.com/lib/fonts/MicrosoftYaHei_Regular.json

import facetype from "./facetype";
...
       world.labelText('label')
       .labelSize(1.2)
       .labelDotRadius(0.4)
       .labelAltitude(0.01)
       .labelDotOrientation(d =>'top')
       .labelColor(d => "#FDCA69")
       .labelTypeFace(facetype)

But running error!

WechatIMG35

@vasturiano
Copy link
Owner

@jinzhe does this help? #26

@jinzhe
Copy link
Author

jinzhe commented Jul 9, 2021

Thank you, it has been resolved!

@jinzhe jinzhe closed this as completed Jul 9, 2021
@dengsong666
Copy link

@jinzhe does this help? #26这有帮助吗? #26
Hello, I am building my Nuxt3 project, I try this solution, assign the imported json value to labelTypeFace, received the following error, can you help me look at it?

globe__gl.js?v=216d8761:50316 Uncaught TypeError: Cannot read properties of undefined (reading 'yMax')
    at createPaths (globe__gl.js?v=216d8761:50316:41)
    at Font.generateShapes (globe__gl.js?v=216d8761:50306:19)
    at new TextGeometry (globe__gl.js?v=216d8761:50280:27)
    at updateObj (globe__gl.js?v=216d8761:52901:28)
    at globe__gl.js?v=216d8761:31741:9
    at Array.forEach (<anonymous>)
    at updateObjs (globe__gl.js?v=216d8761:31737:11)
    at viewDigest (globe__gl.js?v=216d8761:31722:3)
    at threeDigest (globe__gl.js?v=216d8761:51003:10)
    at Function.update11 (globe__gl.js?v=216d8761:52877:5)

This is my code

const globe = Globe().width(400).height(400)(ipVisual.value!)
        .globeImageUrl('//unpkg.com/three-globe/example/img/earth-blue-marble.jpg')
        .labelsData(visitor)
        .labelLat((d: any) => d.lat)
        .labelLng((d: any) => d.lon)
        .labelText((d: any) => d.city)
        .labelSize(() => 1)
        .labelDotRadius(() => 1)
        .labelColor(() => 'rgba(255, 165, 0, 0.75)')
        .labelResolution(2)
        .labelTypeFace(font)
        .pointOfView({ lat: 34, lng: 108, altitude: 1 }, 500)

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

No branches or pull requests

3 participants