got InvalidEntryException when inserting a new feature to a map

2 views
Skip to first unread message

chuang liu

unread,
Sep 21, 2009, 2:52:31 PM9/21/09
to google-map...@googlegroups.com
Hi:

I tried to insert to a new feature to a newly created map by following the example on http://code.google.com/apis/maps/documentation/mapsdata/developers_guide_java.html, and got an InvalidEntryException error.  Could you please help me find out what went wrong?

My code is as follows. The map creation part works correctly because I can see the map has been created.  I got 'mid' from a MapEntry returned by map creation.

      MapEntry gmap = service.insert(mapUrl, mapEntry);
      String tmp = gmap.getId();
      String mid = tmp.substring(tmp.lastIndexOf('/')+1);
      ...
      String KML = "<Placemark>" +
              "<name>Aunt Joan's Ice Cream Shop</name>" +
              "<Point>" +
              "<coordinates>-87.74613826475604,41.90504663195118,0</coordinates>" +
              "</Point></Placemark>";            
           
    createFeature(mid, address, KML);

    public static FeatureEntry createFeature(String mapID, String addr, String KML)
       throws ServiceException, IOException {

      // Use the feature feed's #post URL as the Edit URL for this map
      // Replace userID and mapID with appropriate values for your map
    
      final URL featureEditUrl = new URL("http://maps.google.com/maps/feeds/features/default/" + mapID + "/full");

      // Create a blank FeatureEntry object
      FeatureEntry featureEntry = new FeatureEntry();
       
      try {
        // KML is simply XML so we'll use the XmlBlob object to store it
        XmlBlob kml = new XmlBlob();
        kml.setBlob(KML);

        // Set the KML for this feature
        // Note that the KML should only include one <Placemark> entry
        featureEntry.setKml(kml);

        // Set the tile for the feature. Each atom entry requires a feature
            // This feature title will be displayed within My Maps
        featureEntry.setTitle(new PlainTextConstruct(addr));
      } catch(NullPointerException e) {
          throw new ServiceException("Null Pointer");
      }
       
      // Insert the feature entry using the #post URL
      return service.insert(featureEditUrl, featureEntry);
   }

Roman N

unread,
Sep 21, 2009, 5:58:56 PM9/21/09
to google-map...@googlegroups.com
Hi,

Have you tried adding the KML namespace to the <Placemark>? i.e.

<Placemark xmlns="http://www.opengis.net/kml/2.2">

Thanks,
Roman

chuang liu

unread,
Sep 21, 2009, 7:17:42 PM9/21/09
to google-map...@googlegroups.com
Hi Roman:

Thanks for your reply. I tried with and without the namespace, and both failed.

Regards

Chuang

chuang liu

unread,
Sep 21, 2009, 7:38:21 PM9/21/09
to google-map...@googlegroups.com
Is there a way I can tell if it is a problem with the map URL or a problem with KML string?

Thanks.

chuang

Roman N

unread,
Sep 25, 2009, 5:04:32 PM9/25/09
to google-map...@googlegroups.com
Hi Chuang,

Can you try turning on HTTP logging as per this article:
http://code.google.com/apis/gdata/articles/debugging_client_libs.html#java

and paste the HTTP POST body sent?

Thanks,
Roman

Bobby

unread,
Oct 31, 2009, 3:18:31 AM10/31/09
to Google Maps Data API
By the way, the following JS create-feature sample is missing the KML
namespace:
http://code.google.com/apis/maps/documentation/mapsdata/developers_guide_javascript.html#creating_a_feature

Bobby

On Sep 25, 5:04 pm, Roman N <api.roman.pub...@gmail.com> wrote:
> Hi Chuang,
>
> Can you try turning on HTTP logging as per this article:http://code.google.com/apis/gdata/articles/debugging_client_libs.html...
>
> and paste the HTTP POST body sent?
>
> Thanks,
> Roman
>
> On Mon, Sep 21, 2009 at 4:38 PM, chuang liu <liuchuan...@gmail.com> wrote:
> > Is there a way I can tell if it is a problem with the map URL or a problem
> > with KML string?
>
> > Thanks.
>
> > chuang
>
> > On Mon, Sep 21, 2009 at 4:17 PM, chuang liu <liuchuan...@gmail.com> wrote:
>
> >> Hi Roman:
>
> >> Thanks for your reply. I tried with and without the namespace, and both
> >> failed.
>
> >> Regards
>
> >> Chuang
>
> >> On Mon, Sep 21, 2009 at 2:58 PM, Roman N <api.roman.pub...@gmail.com>wrote:
>
> >>> Hi,
>
> >>> Have you tried adding the KML namespace to the <Placemark>? i.e.
>
> >>> <Placemark xmlns="http://www.opengis.net/kml/2.2">
>
> >>> Thanks,
> >>> Roman
>
> >>> On Mon, Sep 21, 2009 at 11:52 AM, chuang liu <liuchuan...@gmail.com>wrote:
>
> >>>> Hi:
>
> >>>> I tried to insert to a new feature to a newly created map by following
> >>>> the example on
> >>>>http://code.google.com/apis/maps/documentation/mapsdata/developers_gu...,
Reply all
Reply to author
Forward
0 new messages