#Cant pan/zoom on map, google maps platform

3 messages · Page 1 of 1 (latest)

coral raptor
#

Trying to set up basic google maps view in my project but it doesnt let me pan/zoom. As soon as I try it goes back to original position. The street view feature works, however.

I'm getting the message in the attached screenshot in console.

MapComp.tsx

"use client";

import { useState } from "react";
import {
  APIProvider,
  Map,
  AdvancedMarker,
  Pin,
  InfoWindow,
} from "@vis.gl/react-google-maps";

export function MapComp() {
  const api_key = process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY || "";
  const mapId = process.env.NEXT_PUBLIC_MAP_ID;
  console.log({ api_key });
  console.log({ mapId });

  const position = { lat: 53.54, lng: 10 };
  const [open, setOpen] = useState(false); //triggered when clicked marker
  return (
    <APIProvider apiKey={api_key}>
      <div style={{ height: "100vh", width: "100vw" }}>
        <Map zoom={8} center={{ lat: 66, lng: 12 }} mapId={mapId}>
          {" "}
          <AdvancedMarker position={position} onClick={() => setOpen(true)}>
            <Pin
              background={"grey"}
              borderColor={"green"}
              glyphColor={"purple"}
            />
          </AdvancedMarker>
          {open && (
            <InfoWindow position={position} onCloseClick={() => setOpen(false)}>
              <p>Test</p>
            </InfoWindow>
          )}
        </Map>
      </div>
    </APIProvider>
  );
}
sterile summitBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

coral raptor
#

nvm fixed it by changing it to defaultzoom and defaultcenter