任何人都可以告诉我如何在黑莓应用程序开发中使用谷歌地图而不是黑莓地图?在黑莓应用程序中使用Google地图
6
A
回答
9
最近我有一个想法,使用Google Maps website从Browser.Field,但这是不可能的,因为GMaps是基于JavaScript的,它是由黑莓原生浏览器严重支持。
其实有在BlackBerry上使用谷歌地图的2种方式:
- 安装Google Maps Mobile应用程序(见example of use)
- 使用Google Static Maps API生成和设备请求发送图像。这将需要在服务器端执行和Sign Up for the Google Maps API
0
这里是一个小例子:
查看谷歌地图静态图片的形式为:
public class frmMap extends Form implements CommandListener {
Command _back;
MIDlet midlet;
Form dis;
public frmMap(String title, ImageItem img, MIDlet m, Form d){
super(null);
this.midlet = m;
this.dis = d;
_back = new Command("Back", Command.BACK, 1);
addCommand(_back);
append(img);
setCommandListener(this);
}
public void commandAction(Command c, Displayable d) {
if(c == _back){
Display.getDisplay(midlet).setCurrent(dis);
}
}
}
类INET类下载静态图片:
public class INETclass implements Runnable {
private String _location = null;
private HttpConnection inet;
private Pispaal _m;
public String url = null;
public INETclass(String location, Pispaal m){
_location = location;
_m = m;
}
public void run() {
try
{
//Setup the connection
inet = (HttpConnection)Connector.open(url);
inet.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
int rc = inet.getResponseCode();
//Responsecode controleren
if(rc == HttpConnection.HTTP_OK){
//Open input stream to read the respone
DataInputStream is = new DataInputStream(inet.openInputStream());
StringBuffer sb = new StringBuffer();
int ch;
long len = -1;
byte[] buffer = null;
if(_location == null){
len = is.available();
}
if(len != -1){
if(_location == null){
buffer = IOUtilities.streamToBytes(is);
}else{
while((ch = is.read()) != -1){
sb.append((char)ch);
}
}
}
is.close();
if(_location == null){
_m.OnINETComplete(buffer);
}else{
_m.Alert(sb.toString());
}
}else{
_m.Alert("URL " + url + " geeft response code: " + rc);
try
{
inet.close();
}catch(Exception e){
_m.Alert("Error: " + e.getMessage());
}
}
}
catch(Exception e)
{
_m.Alert("Error: " + e.getMessage());
System.out.println("Error: " + e.getMessage());
}
finally
{
try
{
if(inet != null){ inet.close(); }
Thread.currentThread().join(); //Making sure this thread dies
}catch(Exception e){
_m.Alert("Error: " + e.getMessage());
System.out.println("Error: " + e.getMessage());
}
}
}
}
开始下载的按钮操作和加载形式查看图像
public void commandAction(Command c, Displayable d) {
synchronized(c){
String loc = _location.getText();
if(loc.indexOf(",") > 0){
//if(c == _strCommand){
//INETclass inet = new INETclass(loc, this);
//Thread tInet = new Thread(inet);
//tInet.start();
//Alert("Locatie word doorgestuurd. Even geduld");
//}else
if(c == _mapView){
INETclass inet = new INETclass(null, this);
inet.url = "http://www.qeueq.com/gmap.php?location=" + this.lat + "," + this.lon + "&size=" + this.width + "x" + this.height + ";deviceside=true";
Thread tInet = new Thread(inet);
tInet.start();
}
}else{
Alert("GPS locatie is nog niet beschikbaar.");
}
}
}
public void UpdateLocation(double lat, double lon){
String location = lat + "," + lon;
this.lat = lat;
this.lon = lon;
synchronized(location){
_location.setText(location);
INETclass inet = new INETclass(location, this);
Thread tInet = new Thread(inet);
tInet.start();
}
}
优化和编辑代码,以便它符合您的需求。花了一些时间让它正确。
0
相关问题
- 1. 黑莓应用程序在
- 2. 从本地黑莓应用程序的黑莓菜单
- 3. 如何在我的应用程序中显示黑莓地图?
- 4. 如何在黑莓应用程序中添加谷歌地图?
- 5. 在我的黑莓应用程序中使用背景图片
- 6. 应用程序图标替换黑莓
- 7. 黑莓应用程序 - 图库开发
- 8. 在应用程序中使用纬度和经度来生成黑莓地图
- 9. 在黑莓应用程序管理中隐藏应用程序
- 10. 转换黑莓网络作品应用程序到黑莓Java应用程序
- 11. 黑莓:黑莓应用程序中的推送通知
- 12. 在黑莓手机上加载黑莓应用程序
- 13. 应用程序崩溃在黑莓os7
- 14. httpwebrequest在黑莓应用程序
- 15. 有什么方法可以在黑莓Java应用程序中使用Google Analytics?
- 16. 黑莓10手机应用程序错误(谷歌地图API)
- 17. 黑莓地图和位置应用
- 18. 在我的黑莓应用程序中使用OpenStreet Maps
- 19. 在黑莓应用程序中创建“使用Facebook登录”
- 20. 如何在黑莓应用程序中使用软键?
- 21. phonegap应用程序不能在黑莓中使用jQuery和XMLHttpRequest
- 22. 在黑莓应用程序中使用jQuery Mobile
- 23. 关闭应用程序在黑莓中使用jquery移动
- 24. 黑莓地图
- 25. 针对不同黑莓设备的黑莓应用程序
- 26. 如何在黑莓应用程序中显示饼图
- 27. 如何在黑莓中设置应用程序的图标?
- 28. 调用带有地址详细信息的黑莓地图应用程序
- 29. 如何在不安装Google地图应用程序的情况下将Google地图放入黑莓应用程序?
- 30. Google地图与黑莓整合