As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center提供指导。




7年前关闭。




如果要处理数百条折线,那么使用https://developers.google.com/maps/documentation/utilities/polylinealgorithm?hl=sv-SE对折线进行编码会带来很大的性能优势

看来这主要是与API v2一起使用的,而v3能够很好地自行处理大量折线?

我似乎找不到任何基准比较。

最佳答案

将polyling / polygon添加到google map时,使用google.maps.geometry.encoding.decodePath()解码编码路径会获得很大的收益。我有几条包含一千多个点的路径,而不是遍历每个点并创建要添加到Polygon的LatLng,而是通过简单的解码在视觉上更快地加载。

另外,正如Salman指出的那样,通过减少用于通过Ajax传递路径的网络流量,可以带来很大的收益。以Google的example:

Characters
0        1         2         3         4         5         6         7
1234567890123456789012345678901234567890123456789012345678901234567890
38.5,-120.2|40.7,-120.95|43.252,-126.453  // Polyline Decoded: 40 chars
_p~iF~ps|U_ulLnnqC_mqNvxq`@               // Polyline Encoded: 27 chars

仅用3点,我们将点的大小减少了33%。

07-28 03:18
查看更多