Skip to content

Very different maps with the same style.json #1394

@nehalist

Description

@nehalist

Hey there,

I do have a style.json that is being rendered very differently depending on a few things.

First version

    "ol": "^10.3.1",
    "ol-mapbox-style": "^11.0.3",
Image

The map and images are properly rendered, but things like symbol-spacing (and probably more) within my style.json are ignored.

Second version

    "ol": "^10.7.0",
    "ol-mapbox-style": "^13.2.0",
Image

Using the latest versions things like symbol-spacing are being respected, but the images are gone.

Third version (without ol)

Image

For testing I've tried out my style.json in Maputnik which uses MaplibreGL. Here everything seems to work.


Here's how I render the map in my app:

import { Map, View } from "ol";
import { apply } from "ol-mapbox-style";
import { useEffect, useRef } from "react";

export function MapTest() {
  const containerRef = useRef<HTMLDivElement | null>(null);
  const mapRef = useRef<Map | null>(null);

  useEffect(() => {
    if (!containerRef.current || mapRef.current) {
      return;
    }

    const map = new Map({
      target: containerRef.current,
      view: new View({
        zoom: 12,
      }),
    });

    apply(map, "http://localhost:8811/style.json");

    mapRef.current = map;
  }, []);

  return (
    <>
      <div
        ref={(x) => (containerRef.current = x)}
        style={{ width: 500, height: 500, backgroundColor: "#fff" }}
      />
    </>
  );
}

Why are my maps so different? Why are my glphys gone in the latest version?

Any help would be appreciated - thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions