java 获取Google Maps Data API 服务
import com.google.gdata.client.*;
import com.google.gdata.client.maps.*;
import com.google.gdata.data.*;
import com.google.gdata.data.maps.*;
import com.google.gdata.util.*;
import
java.io.IOException;
import java.net.URL;
public class GetMapsFeel
{
public static void main(String[] args){
MapsService myService = new MapsService("applicationName");
try{
myService.setUserCredentials("username","password");
}catch(AuthenticationException e){
e.printStackTrace();
}
try{
printUserMaps(myService);
}catch(ServiceException e){
e.printStackTrace();
}catch(
IOException e){
e.printStackTrace();
}
}
public static void printUserMaps(MapsService myService) throws ServiceException,IOException {
final URL feedUrl=new URL("http://maps.google.com/maps/feeds/maps/default/full");
MapFeed resultFeed = myService.getFeed(feedUrl,MapFeed.class);
System.out.println(resultFeed.getTitle().getPlainText());
for(int i=0;i<resultFeed.getEntries().size();i++){
MapEntry entry=resultFeed.getEntries().get(i);
System.out.println(entry.getTitle().getPlainText());
System.out.println("Summary"+entry.getSummary().getPlainText());
System.out.println("Self Link:"+entry.getSelfLink().getHref()+"\n");
}
}
}
运行时报com.google.gdata.util.AuthenticationException: Error connecting with login URI,是applicationName,username和password的原因,这个我不会写,
------解决方案--------------------
该回复于2013-06-12 14:52:04被管理员删除