Following patch adds the ability to add the Leaflet Scale Control to a map (http://leafletjs.com/reference.html#control-scale).

----
Development is sponsored by www.pax.de

Comments

pebosi’s picture

Status: Active » Needs review
StatusFileSize
new6.53 KB
d0t101101’s picture

Thanks!

I manually applied part of this to v8.x-dev, and noticed duplicate scale controls were rendered on the map. To resolve, I added the following addition to to ensure scale controls are added once and only once in the JS (when multiple layers are in use):

if (this.settings.scaleControl && (count_layers(this.base_layers) === 1)) {
      this.lMap.addControl(new L.Control.Scale(this.settings.scaleControlOptions));
}
rdeboer’s picture

Status: Needs review » Closed (outdated)

You can also use Leaflet in combination with IPGV&M which has Scale Control (imperial/metric) as a configuration option.

orkutmuratyilmaz’s picture

Version: 7.x-1.x-dev » 10.0.13
Status: Closed (outdated) » Needs review
StatusFileSize
new689 bytes

I've also created a patch for Version 10.0.13 and I hope that it works for everyone:)

itamair’s picture

Title: Ability to add Scale Control » Ability to add & configure Scale Control, for Widget, Formatter and Leaflet View Style

  • itamair committed 747d05f3 on 10.0.x
    Issue #2395509 by pebosi, itamair: Ability to add...
itamair’s picture

Status: Needs review » Fixed

With this last commit: https://git.drupalcode.org/project/leaflet/-/commit/747d05f337de271b227f...
this feature request has finally been committed into 10.x dev branch, in a solid and configurable way, according to Leaflet Map Scale Control: https://leafletjs.com/reference.html#control-scale

This is going to be part of next Leaflet 10.0.14 release

orkutmuratyilmaz’s picture

Thank you @itamair:)

_kom__’s picture

Did anybody test this new feature with Lealet Layers installed and more than one map bundle created?
The are some issues for me, but I can't decide if they are Leaflet 10.0.14 release issues, Leaflet Layers issues or maybe even known Drupal core JS bugs.

orkutmuratyilmaz’s picture

@_kom__, I'm using Leaflet Layers with my installation too. What kind of issues do you have? I'm facing an issue like this, but I don't think that the reason is scale control.

Can you share more details with us?

Best,
Orkut

orkutmuratyilmaz’s picture

I'd like to be sure and I've tried to uncheck the "Enable Map Scale Control." on my view's Leaflet display settings, then flushed the cache. Nothing happened. This feature doesn't interfere with my issue, at least.

_kom__’s picture

@Orkut, 1)create two different map bundles, 2)create two different node types with geofield in each represented by these different bundles, 3)disable Scale Control for all bundles in Leaflet settings (or maybe for one). Will all other controls enabled (except +/- buttons) stay in place?

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.