交互式多段线编码器实用程序
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Google 地图可以根据两个或更多纬度/经度坐标生成简单的多段线。
详细了解多段线编码、简单多段线和复杂多段线。
借助此实用程序,您可以在地图上以交互方式或通过输入坐标生成多段线编码。
您还可以反向使用此工具,将折线解码为坐标。
不过,如果您已有编码的多段线或坐标列表(以 GeoJSON linestring 形式),并想在地图上查看该多段线,请使用交互式多段线解码器实用程序。
在地图上以交互方式创建多段线
- 输入地址、邮政编码、位置或地标以将地图居中,然后点击搜索。
- 点击地图以放置表示多段线起点的标记。
- 标记的坐标会显示在纬度和经度框中。
- 点击添加位置按钮。
这样会将坐标添加到位置列表中,并在编码多段线框中生成编码。
- 继续在地图上放置标记,将多段线上的所有位置添加到位置列表和编码多段线。
修改坐标
- 如需删除某个位置,请在位置列表中选择相应位置,然后按删除所选位置。
- 如需删除所有位置并重新开始,请点击删除所有位置。
- 您无法修改位置信息。如需修改营业地点,请删除并重新添加。
如果该位置不在列表末尾,请删除该位置及其后面的所有位置。
通过输入坐标创建折线
- 如果您已有坐标列表,则可以手动在各自的框中输入纬度和经度,而无需放置标记。
将多段线解码为坐标
- 在编码的折线框中输入折线。
- 如果您的折线包含转义字符,请点击相应复选框以取消转义。
- 点击 Decode Polyline。
坐标会显示在位置列表中,并且地图上会绘制相应路线。
此实用程序使用 Maps JavaScript API。具体而言,路径的编码和解码由 google.maps.geometry.encoding
命名空间中的静态方法 encodePath()
和 decodePath()
处理。
如需了解编码方案,请参阅编码多段线算法格式。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[],[],null,["# Interactive Polyline Encoder Utility\n\nGoogle Maps can generate a simple polyline from two or more latitude/longitude coordinates.\nLearn more about\n[polyline encoding](/maps/documentation/utilities/polylinealgorithm),\n[simple polylines](/maps/documentation/javascript/examples/polyline-simple),\nand\n[complex polylines](/maps/documentation/javascript/examples/polyline-complex).\n\nWith this utility, you can generate polyline encodings\ninteractively on a map or by entering coordinates.\nYou can also decode polylines into coordinates\nby using this tool in reverse.\n\nHowever, if you have an existing encoded polyline or a list of coordinates as a\n[GeoJSON linestring](https://geojson.org/)\nand want to view the polyline on a map, use the\n[Interactive polyline decoder utility](/maps/documentation/routes/polylinedecoder).\n\n**Create a polyline interactively on the map**\n\n1. Enter an address, zip code, location, or landmark to center the map and click **Search**.\n2. Click the map to place a marker that represents the start location of your polyline.\n3. The coordinates of your marker show in the **Latitude** and **Longitude** boxes.\n4. Click the **Add Location** button. This adds the coordinates to the **Location list** and generates an encoding in the **Encoded Polyline** box.\n5. Continue to place markers on the map to add all locations on your polyline to the **Location list** and the **Encoded polyline**.\n\n**Editing coordinates**\n\n- To delete a location, select it in the **Location list** and press **Delete Selected Location**.\n- To delete all locations and start over, click **Delete All Locations**.\n- You cannot edit locations. To edit a location, delete and re-add it. If the location is not at the end of your list, delete the location and all the ones following.\n\n**Create a polyline by entering coordinates**\n\n- If you have an existing list of coordinates, instead of placing markers, you can manually enter the latitudes and longitudes in their respective boxes.\n\n**Decode a polyline into coordinates**\n\n1. Enter your polyline into the **Encoded Polyline** box.\n2. If your polyline contains escaped characters, click the checkbox to unescape them.\n3. Click **Decode Polyline** . The coordinates show in the **Location list**, and the line is drawn on the map.\n\n\u003cbr /\u003e\n\n|--------------------------------------------|----------------------------------------------------------------------------------------------------------------------|\n| Input an address to center the map: Search | |------------|---| | Latitude: | | | Longitude: | | | | | || \u003cbr /\u003e **Locations list** |\n| |-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | | **Warning**: Special characters in the encoded polylines returned in JSON responses are escaped. To use these polylines here you must unescape them. | | Encoded Polyline: | |---------------------------------------------------------------------------------| | | | Unescape special characters in the encoded polylines returned in JSON responses | | | || ||\n\nThis utility uses the Maps JavaScript API. Specifically,\nencoding and decoding of paths are handled by the static methods `encodePath()`\nand `decodePath()` in the `google.maps.geometry.encoding` namespace.\nSee the [Encoded Polyline Algorithm\nFormat](/maps/documentation/utilities/polylinealgorithm) for information about the encoding scheme."]]