宣传单:如何在宣传单1中设置无法点击?

时间:2017-02-17 17:12:15

标签: javascript leaflet

在Leaflet 0.7中,此代码使所有线串都无法点击:

typedef NS_ENUM (NSInteger, OBDTraitStyle) {
    OBDTraitStyleCompact,
    OBDTraitStyleMedium,
    OBDTraitStyleFull
};

static NSNumber *_previousGlobalTraitStyleNumber = nil;

@implementation UITraitCollection (OBD)

- (OBDTraitStyle)obd_traitStyle
{
    UIApplicationState state = [[UIApplication sharedApplication] applicationState];
    if (state == UIApplicationStateBackground)
    {
        if (_previousGlobalTraitStyleNumber != nil)
        {
            NSLog(@"App in background - returning previous trait style: %ld", (long)[_previousGlobalTraitStyleNumber integerValue]);
            return [_previousGlobalTraitStyleNumber integerValue];
        }
        else
        {
            NSLog(@"App in background - cannot return previous trait style, as it doesn't exist");
        }
    }

    OBDTraitStyle traitStyle = 0;

    if (self.horizontalSizeClass == UIUserInterfaceSizeClassCompact)
    {
        traitStyle = OBDTraitStyleCompact;
    }
    else
    {
        UIWindow *window = [[UIApplication sharedApplication] keyWindow];

        if (window.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact)
        {
            traitStyle = OBDTraitStyleCompact;
        }
        else
        {
            CGSize viewSize = window.bounds.size;
            BOOL horizontalExpanded = (viewSize.width > 768);

            if (horizontalExpanded == NO)
            {
                traitStyle = OBDTraitStyleMedium;
            }
            else
            {
                traitStyle = OBDTraitStyleFull;
            }
        }
    }

    _previousGlobalTraitStyleNumber = @(traitStyle);
    return traitStyle;
}

@end

这 - clickable:false - 在Leaflet中不起作用1.如何制作不可忽略的线串?

2 个答案:

答案 0 :(得分:1)

在Leaflet 1.0.0中,interactive选项已重命名为更合适interactive

true选项设置为false的图层将对各种鼠标/指针事件做出反应,而不仅仅是点击。如果设置为L.Marker,它将对任何一个做出反应。

如果您在http://leafletjs.com/reference-1.0.3.html查看当前的宣传单文档,您会发现大多数图层(包括L.Polylineinteractive等)都有L.GridLayer选项。您可以在“从交互层继承的选项”部分找到它。

另请注意,L.TileLayerprivate val firms: mutable.Map[String, Integer] = ... private val firmIdFromCode: (String => Integer) = (code: String) => firms(code) val firm_id_by_code: UserDefinedFunction = udf(firmIdFromCode) ... val ds = dataset.withColumn("firm_id", firm_id_by_code($"firm")) 具有该选项,且无法进行互动。

答案 1 :(得分:1)

也许您可以使用 off() 函数或别名 removeEventListener()(请参阅 https://leafletjs.com/reference-1.7.1.html#evented-off)。这可以删除所有注册到点击事件的事件监听器,即:

highlightLayer.removeEventListener('click');

我刚刚有一个类似的用例,我需要防止弹出窗口在实际打开时重新打开。我想知道为什么在过去四年中从未提出过这种解决方案。