Google Maps API in Java ME
Here is a simple library to query Google Maps with the following features:
geocode addresses to their geographic coordinates
retrieve static images with given custom size, format and zoom
To see a live sample of this API, you can check here: Java ME Google Maps API sample MIDlet
Contents
[hide]
1 Get your own Google Maps API Key
2 Use a Proxy server to access Google Map services
3 Source code: GoogleMaps class
4 Utility method for map scrolling
5 Source code: sample usage
Get your own Google Maps API Key
NOTE: Usage of this code with the free Google Maps API Key breaks Google's Terms and Conditions (section 10.8). You should purchase an Enterprise License if you wish to use the Google Maps API as shown in this example.
To use the following code, you should get your own Google Maps API Key. If you have not an API key, you can follow the instructions here: How to use Google Maps data in mobile applications
Use a Proxy server to access Google Map services
Note: this subject (proxy usage) is probably non necessary, still investigating it..
When you sign up to obtain a Google Maps API key, you enter the address that will be able to access Maps services with that key. For this reason, you should setup a Proxy server on that address that will receive HTTP requests from your mobile clients, forwarding them to Google Maps services, giving back Google responses.
In the code below, you should forward the following requests:
http://www.yourserver.com/geo requests to http://maps.google.com/maps/geo
http://www.yourserver.com/staticmap requests to http://maps.google.com/staticmap
Source code: GoogleMaps class
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Vector;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
import javax.microedition.lcdui.Image;
public class GoogleMaps {
private st
相关文档:
JDK1.5中的线程池(java.util.concurrent.ThreadPoolExecut
6
推荐
在多线程大师Doug Lea的贡献下,在JDK1.5中加入了许多对并发特性的支持,例如:线程池。
一、简介
线程池类为 java.util.concurrent.ThreadPoolExecutor,常用构造方法为:
ThreadPoolExecutor(int corePoolSize, int maximumPoolSize,
long keepA ......
Today , i take the first lesson of java ,let me sum up the details:
firstly,about jdk and jre.jdk stands for java development kit,while jre represent java Runtime Environment. jdk is the key of Java. And,jvm(java virtual machine) is the key of jre.
then ,about the platform independence of java.Dur ......
附录A: Java编码规范
一、 Java命名的一般性指导
1. 类名首字母应该大写。属性(成员变量)、方法、对象变量以及所有标识符(如形式参
数、实际参数、局部变量)的首字母应小写,其中包含的所有单词都应紧靠在一起,而
且大写中间单词的首字母。
例如:类名:ThisIsAClassName 属性或方法名:thisIsMethodOrFieldName
......
在 Java 5 环境中,如果用类A去实现接口B (A implements B),在 Java 5 的平台下,A 实现的方法名前是不能添加 @Override 标记的,否则会报如下图所示的错误提示而无法编译:
{{----}}16172
经过尝试和总结,得出下表。
Version
Java 5
Java 6
超类型是 interface,子类型重写的方法能否添加@Override 标记
否
是
......
if(null != agent && -1 != agent.indexOf("MSIE")){
filename = URLEncoder.encode(filename
,"UTF8");
}else if ......