Visualization of map scale

This forum covers all questions dealing with visualization of data within the native PTV xMap interface and the
PTV Developer Raster Maps API
Please remember that additional plugins such as AJAX or Leaflet may be handeled in other forums.
Post Reply
User avatar
Bernd Welter
Site Admin
Posts: 2766
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Visualization of map scale

Post by Bernd Welter »

Hi there,

in older versions of PTV based mapping interfaces there used to be a map scale on the bottom of the map. Now some players asked me where they could switch the visualization of the scale (on/off). The answer to that question is "that depends on the framework you use".

And here's why: through the years the visualization of mapping interfaces performed an evolution
  • from "single tile with control size"
  • to "multiple background tiles + global foreground layers" (both approaches had to deal with the non stable rendering)
  • and finally to a "multiple background tiles" (possible because we implemented stable rendering in xMap2)
With the last stage the necessity of "the map engine itself renders the scale" is no longer given. Nowadays the rendering of scales is done on the mapping framework in use, e.g. Leaflet or xServer.Net. I attached some screenshots so you can compare the output.
mash up approach
mash up approach
If your mapping framework doesn't support a scale from a native perspective you could use this code to determine
  • whether you want to display the scale or not (depends on the min/max latitude)
  • what scale to apply (based on the latitude of your choice)
Here's also some fancy code from Oliver that shows how we apply this native scale in xServer.NET.

Bernd
Attachments
Ajaxmaps (xMap1)
Ajaxmaps (xMap1)
mapscale-ajaxmaps.PNG (65.62 KiB) Viewed 10125 times
LEAFLET  +  PTV XMapServer (2)
LEAFLET + PTV XMapServer (2)
mapscale-leaflet.PNG (7.51 KiB) Viewed 10125 times
xServer.NET + PTV xMapServer 1
xServer.NET + PTV xMapServer 1
xServer.NET + PTV xMapServer 1
xServer.NET + PTV xMapServer 1
PTV Map&Guide Internet (powered by PTV xMapServer1)
PTV Map&Guide Internet (powered by PTV xMapServer1)
mapscale-MGI.PNG (22.12 KiB) Viewed 10125 times
MAP&GUIDE Desktop (powered my PTV MapServer)
MAP&GUIDE Desktop (powered my PTV MapServer)
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
User avatar
Bernd Welter
Site Admin
Posts: 2766
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Re: Visualization of map scale

Post by Bernd Welter »

Here's also another aspect that might be relevant:
Is it true that map frontends / libraries such as LEAFLET or OPENLAYERS hide the display of "scales" at higher zoom levels because, in a single map rectangle, the scaling per pixel varies too much across different latitudes?
Yes, that’s essentially correct. The reason why scales at high zoom levels are often hidden in a map control is due to the projection these tools typically use, e.g. Mercator.

The Web Mercator projection has the following characteristics:
  • Distortion increases with latitude: In this projection, areas near the poles are heavily distorted. While at the equator a pixel on the map corresponds relatively well to a physical distance, this correspondence becomes increasingly inaccurate with higher latitudes. This is because the projection attempts to map the spherical surface of the Earth onto a flat, rectangular map, which inevitably introduces distortions.
    :!: By the way: this also becomes relevant in the context of airline distance calculation: often the used formulas provide acceptable distances within closer ranges but once the used coordinates are located beyond specific latitudes the quality suffers from this effect and also from the earth's shape.
  • Varying scale per pixel: At high zoom levels, the map focuses on smaller and smaller areas, but the distortion along the latitudes means that the scale per pixel on the map varies significantly depending on the latitude. This makes it difficult to provide a single scale that is accurate for the entire visible map window.
  • Scale bar display: Scale bars (e.g., 1 cm = 100 m) are meaningful when they can represent a consistent physical distance across the entire map. However, in high zoom levels and particularly near the poles, this is no longer the case with the Web Mercator projection. This is why many frontends opt to hide the scale or show a simplified version that only applies to the map’s center point.
    Rect is height: 800 px, width = 1'000 px
    Rect is height: 800 px, width = 1'000 px

Solutions or Workarounds:
  • Local scale: Some applications show the scale only for the map's center point, as that’s where the distortion can be most accurately approximated.
  • Alternative projections: For maps where scales at high zoom levels are critical, alternative projections with less distortion (e.g., UTM, Lambert) can be used.
  • User notices: Tools like Leaflet or OpenLayers often offer options to customize how the scale is displayed or calculated based on specific user requirements.
In summary, scales are difficult to display consistently at high zoom levels, primarily because of the distortions inherent in the Web Mercator projection. This is the main reason why many frontends limit or adapt the display of scales.
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
Post Reply