obsidian-map-view icon indicating copy to clipboard operation
obsidian-map-view copied to clipboard

FR: Ability to import lists from google maps

Open Caotenhoch2 opened this issue 2 years ago • 6 comments

I would love to have a feature with which one could import previously in google maps created lists. Probably the easiest way would be for the user to upload their list csv file exported using takeout.google.com. This file is formatted in a way which should make it quite easy to import to the map/notes: Name of the place + ",," + the google.com/maps/place/ link + "," at the end of the line.

When importing this file, a folder with all notes could be created. The name of the note would be the name of the place and the only content of the note could be the geo: link to the place.

This feature would greatly improve changing to the plugin, as it no longer takes an eternity to transfer a list from google to the plugin/obsidian.

Caotenhoch2 avatar Sep 06 '23 16:09 Caotenhoch2

Something like this should do the job, but I don't know how to implement it with obsidian in mind

import * as fs from 'fs';

function read(): void {
    /** Reads the file exported from google as lines */
    const input: string = 'input.csv';
    const lines: string[] = fs.readFileSync(input, 'utf-8').split('\n');
    lines.shift();

    /** Iterates trough valid lines (not null or empty and includes ",,") */
    for (const s of lines) {
        if (s && !s.trim().isEmpty() && s.includes(',,')) {
            const split: string[] = s.substring(0, s.length - 1).split(',,');
	    /** Prints the file out with the place as the filename and the link to the place as their content */
            const file: string = `out/${split[0]}`;
            fs.writeFileSync(file, split[1]);
        }
    }
}

Caotenhoch2 avatar Sep 06 '23 17:09 Caotenhoch2

That's a nice idea. Some time ago I made an experimental import tool in Map View, it is basically still there, and can in theory import KML files generated from Google Maps lists. (I don't recall how, but I managed to export a list to a KML file.) It's unmaintained, and probably broken, but if Takeout uses a CSV file it will probably be even easier.

esm7 avatar Sep 06 '23 17:09 esm7

I've been doing some research on this. Takeout provides Google Map Places Lists in a csv format, but does not include lat/lon in the URL. It looks like:

https://www.google.com/maps/place/Mozzabella+Mercato+delle+Erbe/data=!4m2!3m1!1s0x477fd49401b1db2d:0xfd56772956968f68

I learned the last part of the data pairing is hex for a Customer ID object, likely from Google's Places API. The URL does resolve to one with lat/lon, though.

See https://stackoverflow.com/questions/47017387/decoding-the-google-maps-embedded-parameters and https://stackoverflow.com/questions/18413193/how-do-i-decode-encode-the-url-parameters-for-the-new-google-maps/34275131#34275131 for details.

ngracilla avatar Sep 06 '23 20:09 ngracilla

There are plenty of tools, even online ones, to convert KML files to csv, eg. https://mygeodata.cloud/converter/kml-to-csv

There is also this obsidian plugin which imports csv files to pages https://github.com/farling42/obsidian-import-json which will create json fields from that csv too (not tried by me)

But I think a discussed and developed method would be more useful than trying to shoehorn this into the present plugin

aubreyz avatar Sep 06 '23 22:09 aubreyz

I wrote a simple tool to convert the KML of google earth to .md files for myself. Maybe it could help a bit

https://github.com/architaktus/kml-to-obsidian-markdown

architaktus avatar Sep 28 '23 17:09 architaktus

Sorry for the late reply. This is super useful and I'd love to integrate that. As soon as I find some time for plugins development & maintenance (maybe in the upcoming weeks), I'll prioritize this. Thank you!

esm7 avatar Nov 15 '23 14:11 esm7

Done in 5.5.0.

esm7 avatar Jan 22 '25 16:01 esm7