Page MenuHomePhabricator

Map scale gauge doesn't display on static versions of mapframe maps
Open, LowPublic

Description

Different wikis are configured to display mapframe maps differently. On Wikivoyage, for example, mapframe embedded maps are dynamic. While on most Wikipedias, the embedded maps are static (presumably to speed load time or spare servers?). A user has noticed that the static maps don't display the scale gauge that is shown on the dynamic maps.

The static maps correctly don't show zoom controls, since you can't zoom the static maps. But I can't think of a reason why the scale key, a useful informational item, should not display on the static map. (Note that when dynamic mapframe maps are very small—the lower limit seems to be around 200 px—the scale gauge drops out, which seems correct.)

You can clearly see this behavior on these two map test pages: testwiki, which is configured for static maps, shows no scale markers. While test2 wiki, which is configured for dynamic mapframes, does show the scale.

If anyone knows a reason why this omission is a feature and not a bug, please speak up. Otherwise, I'm putting this into Ready for Pickup.

With gauge (on test2)

Without (on test)

Event Timeline

jmatazzoni triaged this task as Normal priority.May 22 2018, 6:53 PM
jmatazzoni created this task.

A note to say that the Triage team wasn't sure whether this would be easy or very hard. If it turns out to be a big job, then maybe pause and consult as to whether it's worthwhile to continue.

Looking at the code and documentation I see that the staticframe module (ext.kartographer.staticframe) doesn't have access to the resource that manipulates map controls (ext.kartographer.box).

I will look more into it and try to think about an easy/not very hard way to add this functionality to the ext.kartographer.staticframe library. It will be possible only if the staticframe is able to have a Leaflet Map object that could be manipulated with the given properties to render the static map, so the scale could be created in the maps frame (static or not), that's because the Scale Control is part of the DOM and can't be converted into an image on the server-side.

Vvjjkkii renamed this task from Map scale gauge doesn't display on static versions of mapframe maps to shcaaaaaaa.Jul 1 2018, 1:08 AM
Vvjjkkii removed Mholloway as the assignee of this task.
Vvjjkkii raised the priority of this task from Normal to High.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed subscribers: Aklapper, gerritbot.
CommunityTechBot renamed this task from shcaaaaaaa to Map scale gauge doesn't display on static versions of mapframe maps .Jul 2 2018, 4:41 AM
CommunityTechBot assigned this task to Mholloway.
CommunityTechBot lowered the priority of this task from High to Normal.
CommunityTechBot updated the task description. (Show Details)
CommunityTechBot added subscribers: Aklapper, gerritbot.

@Mholloway and @Jhernandez I looked into this one before and IMO it will not be easy to do. The Scale Control is part of Leaflet core (mapclass) and it is not loaded with the staticframe library. I can see two workarounds:

1- Load the map "invisible" (to gain access to map control) and push the scale control from it. It is the fastest workaround but it would mean load a lot of modules that wouldn't be used. It would be the same as loading the dynamic maps just to get the scale and hiding them to show only the static frame.
2- Build a Helper that receive the parameters of the map and returns a DOM object as the "static scale". It would be the same as creating a dynamic map, get its scale as a DOM object and them wiping the map. This still would load a lot of modules, but would no consume resources unnecessarily.
3- Draw the scale into the image on the server side. I am not sure how this could be done and even if it is worth.

The main problem is that the Scale control adjust the Scale DOM object considering the projections of the map and the map canvassize in pixels.

The first solution could be done, but it requires a lot of changes in the staticframe module, it would not be easy but faster than the others. The second one is more intricate, and I would recommend going this way.

I am open to receive feedback on that, in case I am not seeing some better way to solve this.

Thanks for looking more deeply into this, @MSantos. Your analysis confirms my earlier suspicions that this wouldn't be an easy fix. Let's revisit this at the next maps standup to discuss how we want to proceed.

Mholloway added a project: Maps-Sprint.EditedJul 13 2018, 7:21 PM

Pulling this into Maps-Sprint since it's in progress from before, and moving it to Stalled pending resolution at the next standup.

Mholloway reassigned this task from Mholloway to MSantos.Jul 13 2018, 7:21 PM
Mholloway moved this task from Backlog to Stalled/Waiting on the Maps-Sprint board.

My inclination would be to add an option to Kartotherian to bake a scale into the images. There are a few reasons for this

  • Displaying a scale is a common usecase with a static image
  • It gets the scale right while being device independent. With high DPI displays it's difficult to make sure that the image scale and any scaling done on the client are right in all cases
  • It gets the scale right when zooming in and out. There's the same set of problems as high-DPI displays, in slightly different ways.
  • It avoids bringing in a bunch of map and projection specific logic when you want to display an image.
  • Mapnik generally does a better job at rendering text cleanly than client-side options
  • There's a potential for better placement in the future, like avoiding text labels in the area the scale is

I haven't evaluated how difficult this would be, but we already have some capability for rendering markers server-side, and it's similar to that.

MSantos lowered the priority of this task from Normal to Low.Sep 25 2018, 4:04 PM
MSantos removed a project: Maps-Sprint.