Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kml import fails #486

Open
emgalera opened this issue Jun 19, 2021 · 1 comment
Open

kml import fails #486

emgalera opened this issue Jun 19, 2021 · 1 comment

Comments

@emgalera
Copy link

emgalera commented Jun 19, 2021

Hi, thank you for this amazing tool. I'm trying to import a .kml file which I exported from Google Maps. It's a layer with around a thousand markers made from a three-column table (marker title, latitude, longitude) but when I press F4, select the file and click OK, GMapCatcher freezes for two seconds and then shows the map again without any of the markers I'm trying to import. I'd really appreciate your help on figuring out how to make this work.
Thanks in advance.

EDIT: I tried with a kml with only five markers and it doesn't work either.

@heldersepu
Copy link
Owner

I did not even remember about this feature, had to look at the code to see what it was...

def kml_to_markers(strFileName, marker, lookup=False):
from xml.dom.minidom import parseString
def getText(nodelist):
rc = ""
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc = rc + node.data
return rc
try:
with open(strFileName) as f:
fileString = unicode(f.read(), errors='ignore')
dom = parseString(fileString)
PlacemarkElements = dom.getElementsByTagName("Placemark")
except Exception, excInst:
return excInst
for element in PlacemarkElements:
try:
NameElement = element.getElementsByTagName("name")[0]
PointElement = element.getElementsByTagName("Point")[0]
CoordElement = PointElement.getElementsByTagName("coordinates")[0]
except:
pass
else:
Coord = getText(CoordElement.childNodes).split(',')
if len(Coord) >= 2:
strName = getText(NameElement.childNodes)
if lookup:
location, c = search_location(Coord[1] + ' ' + Coord[0])
if (location[:6] != "error="):
strName += " - " + location
marker.append_marker((Coord[1], Coord[0], 10), strName, lookup)
marker.refresh()
dom.unlink()

My educated guess the format for the markers has changed since this feature was introduced, look at that code and look your kml see if it's still valid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants