我在通过 Android 上的新 java api 从功能提要中检索地图功能时遇到了真正的问题。尽管我可以获得包含 id 和标题(来自特定 MapFeed)的 featureFeed,但只要我将 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");