Với tiện ích này, bạn có thể tạo mã hoá đường nhiều đoạn một cách tương tác trên bản đồ hoặc bằng cách nhập toạ độ.
Bạn cũng có thể giải mã đường nhiều đoạn thành toạ độ bằng cách sử dụng công cụ này theo hướng ngược lại.
Tạo một đường nhiều đoạn có tính tương tác trên bản đồ
Nhập địa chỉ, mã bưu chính, vị trí hoặc địa danh để đặt bản đồ vào giữa và nhấp vào Tìm kiếm.
Nhấp vào bản đồ để đặt một điểm đánh dấu biểu thị vị trí bắt đầu của đường nhiều đoạn.
Toạ độ của điểm đánh dấu sẽ xuất hiện trong các hộp Vĩ độ và Kinh độ.
Nhấp vào nút Thêm vị trí.
Thao tác này sẽ thêm toạ độ vào Danh sách vị trí và tạo một mã hoá trong hộp Đường nhiều đoạn được mã hoá.
Tiếp tục đặt điểm đánh dấu trên bản đồ để thêm tất cả vị trí trên đường nhiều đoạn vào Danh sách vị trí và Đường nhiều đoạn được mã hoá.
Chỉnh sửa toạ độ
Để xoá một vị trí, hãy chọn vị trí đó trong Danh sách vị trí rồi nhấn vào Xoá vị trí đã chọn.
Để xoá tất cả các vị trí và bắt đầu lại, hãy nhấp vào Xoá tất cả các vị trí.
Bạn không thể chỉnh sửa vị trí. Để chỉnh sửa một vị trí, hãy xoá rồi thêm lại vị trí đó.
Nếu vị trí đó không nằm ở cuối danh sách, hãy xoá vị trí đó và tất cả các vị trí sau đó.
Tạo một đường nhiều đoạn bằng cách nhập toạ độ
Nếu đã có danh sách toạ độ, thay vì đặt điểm đánh dấu, bạn có thể nhập vĩ độ và kinh độ theo cách thủ công vào các hộp tương ứng.
Giải mã một đường nhiều đoạn thành các toạ độ
Nhập hình nhiều đường vào hộp Hình nhiều đường được mã hoá.
Nếu đường nhiều đoạn của bạn có chứa các ký tự được chuyển đổi ký tự đặc biệt, hãy nhấp vào hộp đánh dấu để huỷ chuyển đổi ký tự đặc biệt.
Nhấp vào Giải mã đường nhiều đoạn.
Toạ độ sẽ xuất hiện trong Danh sách vị trí và đường thẳng sẽ được vẽ trên bản đồ.
Tiện ích này sử dụng Maps JavaScript API. Cụ thể, việc mã hoá và giải mã đường dẫn được xử lý bằng các phương thức tĩnh encodePath() và decodePath() trong không gian tên google.maps.geometry.encoding.
Hãy xem Định dạng Thuật toán đường nhiều đoạn được mã hoá để biết thông tin về sơ đồ mã hoá.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-08-29 UTC."],[],[],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."]]