我有一个真正的问题,通过Android上的新java api从功能Feed中检索地图功能。 虽然我可以获得包含id和title(来自特定MapFeed)的featrureFeed,但只要我将FeatureContent添加到请求中(用于获取地标详细信息),FeatureFeed.executeGet()将返回“400 bad request”错误。 我做错了什么,或者目前实际上是否有错误? 下面是我的一些代码 - 任何信息都会非常感激,因为我已经开始反对这个3天了! (我在FeatureContent类中尝试过“kml:placemark”,“atom:placemark”和“placemark”)
public class FeatureFeed {
@Key("atom:id")
public String id;
@Key("atom:title")
public String title;
@Key("atom:entry")
public List features;
public List<FeatureEntry> maps = new ArrayList<FeatureEntry>();
public static FeatureFeed executeGet( HttpTransport transport,
BuildMapsUrl url) throws IOException {
url.fields = GData.getFieldsFor(FeatureFeed.class);
AtomParser parser = new AtomParser();
parser.namespaceDictionary = Namespace.FEED_NAMESPACE_DICTIONARY;
transport.addParser(parser);
HttpRequest request = transport.buildGetRequest();
request.url = url;
return (FeatureFeed) RedirectHandler.
execute(request).parseAs(FeatureFeed.class);
}
}
public class FeatureEntry implements Cloneable {
@Key("atom:id")
public String id;
@Key("atom:title")
public String title;
@Key("atom:content")
public FeatureContent content;
public FeatureEntry() {
// required
}
public FeatureEntry(String title, FeatureContent content) {
this.title = title;
this.content = content;
}
}
public class FeatureContent implements Cloneable {
@Key("@type")
public String contentType = "application/vnd.google-earth.kml+xml";
@Key ("kml:Placemark") // adding this always fails with Bad Request
public FeaturePlaceMark placemark; // adding this always fails with Bad Request
public FeatureContent() {
//required
}
public FeatureContent(FeaturePlaceMark placemark) {
this.placemark = placemark;
}
}
FEED_NAMESPACE_DICTIONARY.namespaceAliasToUriMap;
feedMap.put("", "http://www.w3.org/2005/Atom");
feedMap.put("kml", "http://www.opengis.net/kml/2.2");
feedMap.put("atom", "http://www.w3.org/2005/Atom");
feedMap.put("exif", "http://schemas.google.com/photos/exif/2007");
feedMap.put("gd", "http://schemas.google.com/g/2005");
feedMap.put("gm", "http://schemas.google.com/g/2008#mapfeature");
feedMap.put("geo", "http://www.w3.org/2003/01/geo/wgs84_pos#");
feedMap.put("georss", "http://www.georss.org/georss");
feedMap.put("gml", "http://www.opengis.net/gml");
feedMap.put("gphoto", "http://schemas.google.com/photos/2007");
feedMap.put("media", "http://search.yahoo.com/mrss/");
feedMap.put("openSearch", "http://a9.com/-/spec/opensearch/1.1/");
feedMap.put("xml", "http://www.w3.org/XML/1998/namespace");
答案 0 :(得分:0)
我也去过那里......
当我删除这句url.fields = GData.getFieldsFor(FeatureFeed.class);
时,该程序运行良好,奇怪但有效。你可以尝试一下。