Skip to content

Is there a way to apply JSON based styles while using AdvancedMarkers? #138

Closed Answered by MauricioRobayo
MauricioRobayo asked this question in Q&A
Discussion options

You must be logged in to vote

This works:

"use client";

import { APIProvider, Map, useMap } from "@vis.gl/react-google-maps";
import { useEffect } from "react";

const apiKey = process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY ?? "";
const mapId = process.env.NEXT_PUBLIC_GOOGLE_MAPS_MAP_ID ?? "";

export default function Page() {
  return (
    <div className="h-screen w-full">
      <APIProvider apiKey={apiKey}>
        <StyledMap />
      </APIProvider>
    </div>
  );
}

function StyledMap() {
  const map = useMap();
  useEffect(() => {
    if (!map) return;
    const styledMapType = new google.maps.StyledMapType(twoToneWithLabels); // https://snazzymaps.com/style/1861/two-tone-with-labels
    map.mapTypes.set("styled_map"

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@MauricioRobayo
Comment options

@shuuji3
Comment options

@MauricioRobayo
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by MauricioRobayo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants