开发者社区> 问答> 正文

打开后如何加载注释图像,而不是之前

0

我在地图上有成千上万条注释。每个注释都是唯一的图像。因此,除非用户要求,否则我不想加载地图上的所有图像。

我的注释具有以下属性:

detailCalloutView: <Image source={{uri: data[i].img_url, cache: 'force-cache'}} style={styles.thumbnail} resizeMode={Image.resizeMode.contain}/>

如何使仅在打开注释时加载图像?我不想通过打开所有注释来粉碎千兆字节的数据。

我想我需要做一些事情,onFocus但是我不确定如何做。

展开
收起
游客ufivfoddcd53c 2020-01-04 14:16:49 826 0
1 条回答
写回答
取消 提交回答
  • 改变这个

    detailCalloutView: <Image source={{uri: data[i].img_url, cache: 'force-cache'}} style={styles.thumbnail} resizeMode={Image.resizeMode.contain}/>
    
    

    对此

    detailCalloutView: <Image source="blanking.jpg" data-annotation={{uri: data[i].img_url, cache: 'force-cache'}}  style={styles.thumbnail} resizeMode={Image.resizeMode.contain}/>
    
    

    然后将事件侦听器添加到地图中的所有图像

    var attr = this.getAttribute("data-annotation");
    this.src = attr;
    
    

    这是要添加的主要内容。现在即使关闭了它也不必再次加载,因为src它将永远是实际的图像。我不会为您包装整个JavaScript,但是您应该从中获得要点。

    2020-01-04 14:17:16
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载