Modified from longdo-map-demo-reactjs
-
Replace
mapKey
value in./src/map/Map.jsx
with your own API key (get one here).const mapKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
-
Import map component (Map) and instance (map).
import { map, Map } from "./map";
-
Call
<Map />
and you should see the map, for example:import React from "react"; import { map, Map } from "./map"; const App = () => { return ( <div style={{ height: "80vh" }}> <Map /> </div> ); };
-
Use
map
instance to use sphere API, for example:map.goTo({ center: { lon: 100.510847, lat: 13.743757 }, zoom: 14 });