Get started
Examples

Street View

Street View

StreetViewControl is a handle a reader drags onto a road. It checks Google's coverage there, then hands you the point to open a panorama.

src/StreetViewMap.tsx
/// <reference types="vite/client" />
import { Mountaya } from "@mountaya/client/browser";
import { MapControls, MapView, StreetViewControl } from "@mountaya/elements-react";
import "@mountaya/elements-react/styles.css";

const client = new Mountaya({
  credential: { publishableKey: import.meta.env.VITE_MOUNTAYA_PUBLISHABLE_KEY },
});

const openPanorama = ([longitude, latitude]: [number, number]) => {
  window.open(
    `https://www.google.com/maps/@?api=1&map_action=pano&viewpoint=${latitude},${longitude}`,
    "_blank",
    "noopener",
  );
};

export const StreetViewMap = () => (
  <div style={{ height: 420 }}>
    <MapView center={[6.8712, 45.9231]} client={client} terrain="topo" zoom={14}>
      <MapControls compass zoom>
        <StreetViewControl
          googleMapsApiKey={import.meta.env.VITE_GOOGLE_MAPS_API_KEY}
          minZoom={12}
          onOpen={openPanorama}
        />
      </MapControls>
    </MapView>
  </div>
);

Install @googlemaps/js-api-loader beside the packages. The imagery is Google's, so the key is your Google Maps API key.

Next steps

Last updated