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
相关文档:
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 ......
本文对 Java Debug Interface(JDI)及其使用进行了介绍,并通过实现一个多线程分析器的示例应用,演示了如何利用 JDI 开发自己的多线程调试程序。该示例分析器在独立于目标程序的前提下,以单个线程流为单位,帮助追踪记录多线程的执行过程信息。
多线程环境下的程序调试是让开发者头痛的问题。在 IDE 中通过添加断点的方 ......
Java Mail无法解析带分号的收件人列表的问题
今天同事碰到一个问题,使用JAVA MAIL收取邮件时,如果收件人是个列表,且收件人列表是以分号进行分割的,则JAVA MAIL就会出现异常,不能正常解析,抽空看了一眼,自己写了个简单demo,很简单,例如:
@Test
public void te ......
估计学习java的买了Bruce Eckle《Thinking In Java 4th Edition》的新手们(我也是),估计多会遇到一个问题:
编译时import static net.mindview.util.Print.*;找不到相应的包,print方法就用不了。下面把我的操作方法贴出来,希望能帮到你。
1、把书本的源代码 ......
计算某一月份的最大天数
Calendar time=Calendar.getInstance();
time.clear();
time.set(Calendar.YEAR,year); //year 为 int
time.set(Calendar.MONTH,i-1);//注意,Calendar对象默认一月为0
int day=time.getActualMaximum(Calendar.DAY_OF_MONTH);/ ......