Friday, May 8, 2015

Google Maps kml files are now zipped kmz files

Apparently I'm bad at keeping up to date when APIs are changed. I looked at TacoTacoTruck recently and it failed to load any map data. It seems that instead of giving a plaintext kml file as it used to, Google Maps returns the file in zip format (kmz), even if you ask for a kml file.

So it needs to be unzipped. Here's some code:

class Fetch(webapp2.RequestHandler):
    def get(self):
        # urlToUse is just a little hardcoded map of a filename as key and the url as the value
        url = urlToUse[self.request.path]
        if url is None:
            print("unexpected path: %s" % self.request.path)
        cachedData = memcache.get(self.request.path)
        if cachedData is not None:
        startDownloadTime = time.time()
        result = urlfetch.fetch(url)
        if result.status_code == 200:
            elapsed = time.time() - startDownloadTime
            print("downloaded %s in %s seconds" % (url, elapsed))
            bytes = io.BytesIO(result.content)
            zip = zipfile.ZipFile(bytes)
            # retrieve the file name of the first (and only) file in the zipfile
            firstName = zip.namelist()[0]
            print("unzipping %s" % firstName)
            # unzip it into contents
            contents =
            memcache.set(key=self.request.path, value=contents, time=cacheTime)
            print("can't fetch kml file for %s. Status=%s" % (self.request.path, result.status_code))

Friday, May 1, 2015

Donors, thank you!

In the past two months I've received several in-app purchase donations for my Napkin paint program. Thank you, kind people!

Small but useful updates to MapTag

Due to the increasing number of user-generated panorama shots being uploaded to Google, it's been harder to find a game where you can actually navigate. I was playing today and got 4 user panoramas in a row! So I added a check to look for "Google" in the copyright info. This should nearly eliminate getting a user-generated pano.

Another minor annoyance came after you got the score window. You could click it and it would close, but the map where you made your guess didn't close along with it. Now it does.

Finally, I've added a new themed game called "New to the City." It places you in a random location but within a specific city. There's currently 24 cities to choose from, so go get lost!

Happy wandering!