uploading kml file via API -> failure

71 views
Skip to first unread message

Arkadiusz Miskiewicz

unread,
Jul 15, 2010, 1:53:41 PM7/15/10
to Google Maps Data API
Documentation says that it's possible to upload kml file via API.

It's documented here:
http://code.google.com/intl/pl/apis/maps/documentation/mapsdata/developers_guide_protocol.html#uploading_kml
with an example of kml file being uploaded.

I'm following that example - doing ClientLogin authorization and then
POSTing example kml file from documentation. Unfortunately that ends
with:

HTTP/1.1 400 Bad Request

I've tried doing the same with CSV example and ... it worked fine.

So is:
- google api broken ?
- documentation not updated ?
- some other problem ?

Solution is welcome.

Michael

unread,
Jul 22, 2010, 10:17:53 AM7/22/10
to Google Maps Data API
Ditto here, and same conclusions - API/Docs problem, presumably.


POST /maps/feeds/maps/default/full HTTP/1.1
User-Agent: curl/7.19.4 (universal-apple-darwin10.0) libcurl/7.19.4
OpenSSL/0.9.8l zlib/1.2.3
Host: maps.google.com
Accept: */*
Content-Type: application/vnd.google-earth.kml+xml
Authorization: GoogleLogin auth="xxxxxxxxxxxxxxxxx"
GData-Version: 2.0
Content-Length: 507

<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Folder>
<Placemark>
<name>Hello</name>
<description>Greetings from Lima!</description>
<Point>
<coordinates>-11.968312,-77.066395</coordinates>
</Point>
</Placemark>
<Placemark>
<name>There</name>
<description>Out There Down Under</description>
<Point>
<coordinates>-38.51512,145.34502</coordinates>
</Point>
</Placemark>
</Folder>
</kml>





HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=UTF-8
Date: Thu, 22 Jul 2010 14:13:53 GMT
Expires: Thu, 22 Jul 2010 14:13:53 GMT
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Cache-Control: private, max-age=0, proxy-revalidate
Transfer-Encoding: chunked
Connection: Keep-Alive

b
Bad request
0

Michael

unread,
Jul 22, 2010, 10:27:23 AM7/22/10
to Google Maps Data API

Jeremy Mason-Herr

unread,
Jul 22, 2010, 2:03:24 PM7/22/10
to google-map...@googlegroups.com
The way to make this work is the following: (working example at
www.adventureseed.com)

Create a map with the API
(In order for a map to be 'API visible' it must be created with the API.)
Using the interface at maps.google.com, create something that looks
like what you want to add with the API
Now using the API, download this feature's kml. Remove any parts that
are specific to that item. This is your
template. Use this template and string substitution to make kml for
new features.

here's my template for linestrings:

'<ns0:entry xmlns:ns0="http://www.w3.org/2005/Atom"
xmlns:ns1="http://schemas.google.com/g/2005"><ns0:category
scheme="http://schemas.google.com/g/2005#kind"
term="http://schemas.google.com/maps/2008#feature"
/><ns0:author><ns0:name>adventureseed</ns0:name></ns0:author><ns0:content
type="application/vnd.google-earth.kml+xml"><ns2:Placemark
xmlns:ns2="http://www.opengis.net/kml/2.2"><ns2:name>%s</ns2:name><ns2:description>%s</ns2:description><ns2:Style><ns2:LineStyle><ns2:color>%s</ns2:color><ns2:width>%s</ns2:width></ns2:LineStyle></ns2:Style><ns2:LineString><ns2:tessellate>0</ns2:tessellate><ns2:coordinates>%s</ns2:coordinates></ns2:LineString></ns2:Placemark></ns0:content><ns0:contributor><ns0:name>adventureseed</ns0:name></ns0:contributor><ns0:title>%s</ns0:title></ns0:entry>'

and my template for points:
'<Placemark><name>%s</name><description><![CDATA[<a
href="http://adventureseed.appspot.com/seed/view/%s">%s</a>%s...]]></description><Point><coordinates>%s,%s</coordinates></Point></Placemark>'


Now make a Feature from that string:

map_item = gdata.maps.data.Feature()
map_item.content = gdata.maps.data.KmlContent(kml=my_map_item_string)
map_item.title = atom.data.Title(text=title)

And upload this!

I'm not sure if this is the only way, but I spent a long time trying
to get other, more documented methods to work and that failed pretty
hard.

Best of luck.

Sent from my iPhone

On Jul 22, 2010, at 7:27 AM, Michael <mic...@tyson.id.au> wrote:

> Submitted issue 2590: http://code.google.com/p/gmaps-api-issues/issues/detail?id=2590
>
> --
> You received this message because you are subscribed to the Google
> Groups "Google Maps Data API" group.
> To post to this group, send email to google-map...@googlegroups.com
> .
> To unsubscribe from this group, send email to google-maps-data...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/google-maps-data-api?hl=en
> .
>

Michael

unread,
Jul 23, 2010, 7:55:39 PM7/23/10
to Google Maps Data API
Hmm, I have no idea why this works and the example in the docs
doesn't! I'm putting this one in the too-hard basket for now, and
using a different API method =)

Thanks for the info, though!

Eric

unread,
Jul 27, 2010, 12:57:45 AM7/27/10
to Google Maps Data API
Everyone please star the issue 2590 that Michael created if you are
running into this problem. I am seeing the same issue where I am
following the example exactly, but get a 400 - bad request.

Abedon Chen

unread,
Jul 28, 2010, 6:08:17 PM7/28/10
to Google Maps Data API
Same for me. Already stared the issue 2590.

Jeremy Mason-Herr

unread,
Jul 28, 2010, 6:40:20 PM7/28/10
to google-map...@googlegroups.com
if you're getting 400 you may have your request url wrong.  I had problems with this and worked around it by changing
my post request to

http://maps.google.com/maps/feeds/features/<userid>/<mapid>/full

also, using 'default' as the user id didn't work
what i'm using as user id is the number that you can find in the feed, but you can also find at the 'my maps' page. 
if you click 'send' you will see a number that looks like this:

msid=109850355599707643870.00048c7a47cc614d67b1

109850355599707643870 is your user id

00048c7a47cc614d67b1 is your map id

i hope i'm right...

On Wed, Jul 28, 2010 at 3:08 PM, Abedon Chen <softs...@gmail.com> wrote:
Same for me. Already stared the issue 2590.

Abedon Chen

unread,
Jul 29, 2010, 10:05:58 AM7/29/10
to Google Maps Data API
Hey Jeremy,

Thanks for you inputs. But I'm talking about creating a new map by
uploading a pure kml. How do I get the <mapid> before the map is
created?

Also, I tried to post a kml to the url you brought up. Http 415 error
was returned saying "Content-Type application/vnd.google-earth.kml+xml
is not a valid input type". So the way you suggest seems not working
for this case.

Jeremy Mason-Herr

unread,
Jul 29, 2010, 1:10:46 PM7/29/10
to google-map...@googlegroups.com
sorrry.  i thought you were talking about uploading a feature to a map.  i have no idea then.  i've always made maps the way its done in MapsExample.py
best of luck


--
Reply all
Reply to author
Forward
0 new messages