【问题标题】:Set marker image width/height in jVectorMap在 jVectorMap 中设置标记图像的宽度/高度
【发布时间】:2018-10-17 20:45:23
【问题描述】:

不幸的是,在创建新 jVectorMap 时设置 markerStyle 不会影响 SVG 图像属性。

window.mapMarkers = [];
window.mapMarkers.push({
    name: 'Test',
    coords: [12.345, 12.345]
});

new jvm.Map({
    container: $('#map'),
    map: 'en',
    series: {
        markers: [{
            attribute: 'image',
            scale: { 'marker': 'marker.png' },
            values: window.mapMarkers.reduce(function(p, c, i) { p[i] = 'marker'; return p; }, {})
        }]
    },
    markerStyle: {
        initial: {
            width: 42, height: 58
        }
    }
});

如何在不更改jvectormap library 源代码的情况下覆盖地图中的 SVG 宽度/高度图像属性?通过 CSS 设置尺寸仅适用于 WebKit,但不适用于 Firefox 和 Co.

【问题讨论】:

标签: jquery svg jvectormap


【解决方案1】:

查找“svg-image-element.js”。 默认情况下,svg-image 的大小是使用的图像的大小。

that.width = img[0].width;
that.height = img[0].height;

要更改它,只需将 img[0].width / height 更改为您需要的任何值。

【讨论】:

    猜你喜欢
    • 2012-03-01
    • 2014-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-07
    • 2012-09-05
    • 2019-01-02
    相关资源
    最近更新 更多