如何在不崩溃浏览器的情况下编辑大型多边形? [英] How can I edit large polygons without crashing the browser?

查看:71
本文介绍了如何在不崩溃浏览器的情况下编辑大型多边形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由12.5K点的单一路径组成的多边形。当我将它标记为可编辑 shape.setEditable(true)时,我的选项卡空白处的内存使用量大约为800M,直到浏览器终止进程。



我注意到标记一个较小的多边形,只有大约1K点,因为可编辑需要一段时间来处理和消耗大约100M的内存。我认为时间用于计算中点,并为所有节点和中点分配对象和事件处理程序。



有没有办法在不使用太多内存的情况下编辑大型图形?



Google地图制作工具拥有(has?)相关问题,其中有人建议标记多边形的特定部分进行编辑。我想我会尝试一下,如果没有办法解决这个问题。

我创建了 gmaps-large-polygons 库来解决这个问题。当多边形被标记为可编辑时,它将多边形的路径分割成给定大小的线段,并且只允许您一次编辑一个线段。这可以防止您一次为整个多边形渲染数千个编辑顶点,从而消耗所有内存。


I have a polygon that consists of a single path with 12.5K points. When I mark it as editable shape.setEditable(true), the memory usage for my tab skyrockets to about 800M until the browser kills the process.

I've noticed that marking a smaller polygon, with only about 1K points, as editable takes a while to process and eats up about 100M of memory. I figure the time is spent calculating midpoints and allocating objects and event handlers for all of the nodes and midpoints.

Is there a way to edit large shapes without using so much memory?

Google Map Maker had (has?) a related problem in which someone suggested marking a specific portion of the polygon for editing. I suppose I'll try that if there's no way around the issue.

解决方案

I created the gmaps-large-polygons library to solve this problem. When polygons are marked as editable, it splits the ppolygon's paths into line segments of a given size and only allows you to edit one segment at a time. This prevents you from using up all your memory by having thousands of edit vertices rendered for the whole polygon at once.

这篇关于如何在不崩溃浏览器的情况下编辑大型多边形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆