Giter VIP home page Giter VIP logo

Comments (8)

puka-tchou avatar puka-tchou commented on May 29, 2024 2

One solution could be to add an optional property to the constructor that would be an array of markers and then use a similar technique as the one discussed in Markers in the Map are not printed #32

   this.markers.forEach((x, i) => {
        mapRef.current = mapRef.current.addSource(`point${i}`, {
            type: "geojson",
            data: {
                type: "Point",
                coordinates: [x.position.lng, x.position.lat],
            },
        });

        mapRef.current = mapRef.current.addLayer({
            id: `point${i}`,
            source: `point${i}`,
            type: "circle",
            paint: {
                "circle-radius": 8,
                "circle-color": "red",
                "circle-stroke-width": 1,
                "circle-blur": 0.5,
            },
        });

credits to @TARMAH

from maplibre-gl-export.

JinIgarashi avatar JinIgarashi commented on May 29, 2024 2

@PeterPilley, @puka-tchou, @Hags7978 ,@TARMAH

I finally managed this long term issue of exporting marker via PR #122. I used @TARMAH's approarch to export markers as circle layer, but the plugin get marker's coordinates info from DOM element directly. So, you don't need to pass markers additionally.

I added markerCirclePaint option to allow to change circle style flexiblely. You can pass maplibre/mapbox expression to the plugin.

Please try the latest version of plugin.

  • maplibre-gl-export: 3.4.0
  • mapbox-gl-export: 3.1.0

from maplibre-gl-export.

JinIgarashi avatar JinIgarashi commented on May 29, 2024 1

#15 is also quite similar with this bug

from maplibre-gl-export.

JinIgarashi avatar JinIgarashi commented on May 29, 2024

@puka-tchou Thank you for the issue. This plugin only can export current style.json in map object. There is no style information about marker, that is why it is not exporting with custom marker. You have to add your own markers after this source code.

const renderMap = new MaplibreMap({
container,
style,
center: this.map.getCenter(),
zoom: this.map.getZoom(),
bearing: this.map.getBearing(),
pitch: this.map.getPitch(),
interactive: false,
preserveDrawingBuffer: true,
fadeDuration: 0,
attributionControl: false,
// hack to read transfrom request callback function
transformRequest: (this.map as any)._requestManager._transformRequestFn,
});

Maybe the plugin can have an optional parameter to apply any additional style into exported map.
Feel free to make pull request to the repository to add this feature.

from maplibre-gl-export.

JinIgarashi avatar JinIgarashi commented on May 29, 2024

watergis/mapbox-gl-export#32 is also the same issue with maplibre version

from maplibre-gl-export.

puka-tchou avatar puka-tchou commented on May 29, 2024

I'm currently reading the source code, I think that it might be more easily solved on my side. I can see that the generate() method loads the canvas of the map and then prints it:

    const renderMap = new MaplibreMap({
      container,
      style,
      center: this.map.getCenter(),
      zoom: this.map.getZoom(),
      bearing: this.map.getBearing(),
      pitch: this.map.getPitch(),
      interactive: false,
      preserveDrawingBuffer: true,
      fadeDuration: 0,
      attributionControl: false,
      // hack to read transfrom request callback function
      transformRequest: (this.map as any)._requestManager._transformRequestFn,
    });

    renderMap.once('idle', () => {
      const canvas = renderMap.getCanvas();

the solution might be to add the markers on the map using a symbol layer instead of adding them via new maplibregl.Marker({element}).setLngLat(lngLat).addTo(map); when I'm creating the map in my code.

But anyway, it would be nice to have the option right inside of maplibre-gl-export, but I'm not sure that it's feasible.

from maplibre-gl-export.

PeterPilley avatar PeterPilley commented on May 29, 2024

Hi was there any update on this issue? or update on progress.

from maplibre-gl-export.

Hags7978 avatar Hags7978 commented on May 29, 2024

Push

from maplibre-gl-export.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.