任何人都可以告訴我如何在黑莓應用程序開發中使用谷歌地圖而不是黑莓地圖?在黑莓應用程序中使用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地圖與黑莓整合