MapGenie - Smaller Icon Size

Makes the icons smaller on the map, so you can see more of the map at once.

当前为 2023-04-20 提交的版本,查看 最新版本

// ==UserScript==
// @name         MapGenie - Smaller Icon Size
// @namespace    https://github.com/Auncaughbove17/my-userscripts/
// @version      0.1
// @description  Makes the icons smaller on the map, so you can see more of the map at once.
// @author       Alistair1231
// @match        https://mapgenie.io/*
// @icon         https://icons.duckduckgo.com/ip2/mapgenie.io.ico
// @license GPL-3.0
// ==/UserScript==

(function () {

    function setIconSize() {
      // Get the current zoom level
      var zoom = map.getZoom();
      var maxZoom = map.getMaxZoom();
      var minZoom = map.getMinZoom();
      // Loop through all the symbols on the 'locations' layer
      map.queryRenderedFeatures({
        layers: ['locations'],
        filter: ['==', '$type', 'Point']
      }).forEach(function (feature) {
        // Set the new icon size based on the current zoom level
        var newIconSize = Math.max(0.2, Math.min(1, (zoom - 4) / maxZoom)); // Adjust the minimum and maximum size as needed
        map.setLayoutProperty('locations', 'icon-size', newIconSize, ['==', 'locationId', feature.properties.locationId]);
      });
    }
    if (typeof map !== "undefined") {
      map.on('zoom', function () {
        setIconSize();
      });
    }
  })();