The Cartographer's Lament
February 28, 2021 10:19 PM   Subscribe

How do I complete a shape made from an extended line in Google Maps?

I've been working on a project in Google Maps that involves highlighting certain areas. I understand how to use the Draw a Line function to highlight an area by using multiple line segments that share a start and end point to create a shape. So far so good, but...

While creating a particularly large and tricky shape I somehow accidentally made the line set before I was done with it. I didn't figure this to be a problem; I right-clicked on my last point and selected Extend Line. Everything seemed fine but when I connected my last line segment back to the starting point it didn't create a highlighted shape.

This is a large shape made of dozens of line segments and I don't want to have to recreate it. Is there a way to get Google Maps to recognize this as a shape so I don't have to start from scratch?

Any help would be appreciated.
posted by Parasite Unseen to Computers & Internet (3 answers total)
 
This can be done but not in the browser. It requires a bit of fussing with XML.

Don't be put off by the length of the instructions -- it's really easy, but it might be confusing if you aren't that familiar with common GIS and XML data formats. It does assume that your end-point is actually has the exact same coordinates as your start point -- otherwise your shape will be corrupt.

The general method is going to be to download the data as XML data, take the coordinates that you created when you drew the line, but then wrap them into polygon object instead of a line object, and finally reupload to your map.

1. Drag your shape onto a new layer called "MyLayer" or whatever -- this is to keep things neat.

2. On MyLayer -- create a new, very simply polygon shape, like a triangle -- this will help you cheat a bit later.

4. Export MyLayer to a KML (not a KMZ!) file -- this is Google Earth XML data. Don't export your whole map, just MyLayer...Export options are in the three-dots menu up by your Map's name.

5. Open MyLayer.kml in a text editor -- there's a ton of info in there including styles like line widths and colors -- but what you care about are Placemarks which are Google's stupid name for features (start and end with ...

6. Find your line -- it will be a and your triangle -- which will be a . You'll see each has a list of XY coordinates where the vertices are. Copy and paste coordinates from the LineString over those from the Polygon. You can actually check that the last coordinate is precisely the same as the first here -- and if not, just fix it.

7. Optionally delete the old LineString Placemark (you need to delete the whole block from ... , but just the one that has the LineString)

8. Save your KML file with a new name (just in case) and if you've done everything right, you should be able to now reimport it into MyMaps.
posted by voiceofreason at 1:54 AM on March 1, 2021 [1 favorite]


Ach...accidentally deleted something from Step 7 -- it should say "whole block from to " containing the LineString.

I should mention that half the instructions are just little hacks to make your life easier. Using a new layer reduces the number of placemarks so you don't get mixed up -- and adding the new polygon makes it so your KML file will already contain an example where the correct tag structure for a polygon is already present in your file and you can just replace the coordinates.
posted by voiceofreason at 2:00 AM on March 1, 2021


voiceofreason, I'm guessing that your instructions include <stuff-between-angle-brackets> that the Mefi text editor has interpreted as non-whitelisted HTML tags and removed. To make a < character appear on Mefi you need to enter it using its HTML entity code &lt; instead.

If you then use the Preview button to preview your post you will also find that all your > characters have been replaced with &gt; but there's no need to keep entering those that way as they can't be mistaken for something that introduces a tag.
posted by flabdablet at 2:41 PM on March 1, 2021


« Older How to talk to a doctor about anxiety?   |   Regaining normalcy post pandemic? Newer »
This thread is closed to new comments.