how I can implement geoEqualEarth() and geoPath() functions from d3-geo
I assume that what you mean by that is using those functions, which are defined in the JavaScript library d3-geo, from Scala.js.
In general, to use JavaScript libraries from Scala.js, you either define facade types for the library, or reuse one that is already existing, perhaps through ScalablyTyped. How the facades are declared depends mostly on what the API looks like, and how it's supposed to be used.
Just trying to make your example snippets valid, I would aim for
@js.native
trait Projection extends js.Object {
def scale(factor: Double): this.type
def translate(v: js.Tuple2[Double, Double]): this.type
}
@js.native
trait Path extends js.Object {
def projection(p: Projection): Path
def apply(obj: js.Any): Something = js.native
}
// import { geoEqualEarth, geoPath } from "d3-geo"
object D3GeoFunctions {
@js.native
@JSImport("d3-geo", "geoEqualEarth")
def geoEqualEarth(): Projection = js.native
@js.native
@JSImport("d3-geo", "geoPath")
def geoPath(): Path = js.native
}
although a lot of this is guesswork based on your snippet and skimming the d3-geo readme.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…