Google 静态地图 API 多边形 url 太长

Google Static Map API multi polygon url too long

我正在使用静态 google 地图生成 url 地图上的多个多边形。但是坐标很长,url超过八千字

这里有我使用 2 个多边形的 url: static map(url whitout 键及其获取错误 400) 26345 个字符。

有没有办法在不降低精度的情况下减少它? 我也使用ruby,如果有一个解决方案可以与ruby一起使用,那就太好了。

对于 example you provided, encoding the paths 的多边形有效。

我使用了 fiddle and the Google Maps Javascript API to encode the paths. Resulting live static map(缩小了一些以提供上下文)。

编码算法描述in the Google Maps documentation and there is at least one ruby implementation

<html>

<body>
  <img src='https://maps.googleapis.com/maps/api/staticmap?center=0.04096,41.65521&zoom=12&size=1200x800&path=fillcolor:red%7Cweight:1%7Ccolor:blue%7Cenc:kxFy~e}FD?HCDC??DE@EBIBU@GBE?A?CAAA?ACGCGCSEGCAAECCCCG@E@GJSBODU@G@C@IFMBEBG@E@G?G??AGCEAGCGGMGMAE?I?A?A?ABGJSBG?ABCFU@EBGFK@?DEBC@ADE@G@EBG@?@E@C@ARYBI@CBG@GFY@K?C?A?GEMIOCCACCCCECMAG?K?A@C?C@GBENQ@CBCHM?AFK@C?A@G@G?C?CAEAGEECCEAI?OFCBC@MHKJEDUNEDGBI@QDIBG@A?GBGBGDCBA@IJGHGHIJEFEDEDA???EB?@CBGFCDELGLA?EDGBGBQDIBG@IAIAGCICEACE?EAE?A?ECECACAICIAC?EAGA_@AI?]@Y?C?C@A???A?C@????G@QDGBA?MFA@C@I@IAA???EAIACA?CBGHKFE^Y@ABA@A@ADC??FEFCXIFCHCHC^OHCBAHC@A|@YZG??PGFC@ABA@E?A?C?A?ACCEECGAAMOIMEEEEEGCACAGCGCEEEEA?CECEeAN_ANoCb@{LnB??THRNQFs@Pu@Fm@BQKMKA@iDh@KBgDh@VHB?\LhA^`AZ`AZjA`@x@XVH??B@F@??B@@@NDTHt@Vp@Rh@NtA^z@RhAZ`AVl@Nd@LXFdAXl@N\JRDr@R@?LDf@LF@`@LVFp@Pj@NRDNDTBLBJ@&path=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