mapwarper icon indicating copy to clipboard operation
mapwarper copied to clipboard

Support Mapbox custom layers with special characters

Open planemad opened this issue 11 months ago • 1 comments

Thank you @timwaters for this incredibly useful tool ❤️ . It is being used to democratize access to landuse maps in India https://github.com/publicmap/amche-goa/issues/23

We have a custom map layer of village borders made with Mapbox to help with the rectification, but are unable to add it to map warper.

This is a sample png tile https://api.mapbox.com/styles/v1/planemad/cm3gyibd3004x01qz08rohcsg/tiles/256/5/19/13@2x?access_token=pk.eyJ1IjoicGxhbmVtYWQiLCJhIjoiY2x2MzZwbGRyMGdheDJtbXVwdDA4aDNyaCJ9.nbvz6aNGQo68xa4NtWH26A:

Sample tile

While adding as a custom layer, the special characters is being removed and the url breaks.

https://api.mapbox.com/styles/v1/planemad/cm3gyibd3004x01qz08rohcsg/tiles/256/3/3/6.nbvz6aNGQo68xa4NtWH26A

Screenshot 2025-01-06 at 8 56 47 AM

Is there a workaround or some other way to add such a layer?

planemad avatar Jan 06 '25 04:01 planemad

I think the extension picking logic is picking 'nbvz6aNGQo68xa4NtWH26A' as the tile type.

function a(e) {
        var t = e.template
          , r = ""
          , a = e.type
          , o = ""
          , n = t.split("/")
          , i = n.slice(0, n.length - 3)
          , s = i.join("/") + "/"
          , l = t.split(".").pop();
        if (i.length <= 0)
            return !1;
        "Custom" == a ? (r = I18n.warp.custom_layer,
        o = I18n.warp.custom_layer + " " + s) : o = (r = a + ": " + e.title.substring(0, 20)) + " " + s;
        var c = new OpenLayers.Layer.TMS(r,s,{
            type: l,
            getURL: osm_getTileURL,
            displayOutsideMaxExtent: !0,
            transitionEffect: "resize",
            attribution: o
        });
        c.setVisibility(!0),
        c.setIsBaseLayer(!0),
        to_map.addLayer(c),
        to_map.setBaseLayer(c),
        to_layer_switcher.maximizeControl(),
        jQuery("#add_layer").hide()
    }

Updating the UI using tampermonkey to add an extension override field might be an option

ramSeraph avatar Jul 30 '25 11:07 ramSeraph