2009-09-07 25 views

cevap

9

Geçtiğimiz günlerde, Browser.Field numaralı telefondan Google Maps website'u kullanma konusunda bir fikrim vardı, ancak GMaps JavaScript'e dayalı olduğundan ve Blackberry yerel Tarayıcı tarafından kötü şekilde desteklenmediğinden bu mümkün değil.

0

biraz örnektir:

Google Maps Statik resmi görüntülemek için Biçim:

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); 
     } 
    } 

} 

sınıf inet sınıfı statik indirmek için resim:

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()); 
      } 
     } 
    } 
} 

indirme ve yükler geri arama eylemi başlatır düğme eylemi görüntüyü görmek için formu görüntüyü tıklatın

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();   
     } 
    } 

Gereksiniminize uygun olacak şekilde kodu daraltın ve düzenleyin. Doğru yapmak için biraz zamanımı aldım.

0

Artık BlackBerry haritaları yerine Google Haritalar'ı görüntüdeki gibi kendi verilerimizle kullanmak mümkündür. enter image description here

size uygulamadan ApplicationDescriptor kullanarak google maps çağırabilir kendi konumlarını/belirteçler göstermek için google maps kullanmak arıyorsanız. CodeModuleManager.getModuleHandle("GoogleMaps");'u kullanarak cihazdaki google haritalarını kontrol edin, sıfır olmadığı durumlarda kullanılabilir olduğu bir tamsayı döndürür. Daha sonra, KML dosyanızda yer ekleyebilir, KML dosya etiketlerini kullanarak konum işaretleyicilerini bile özelleştirebilirsiniz.

Max ile bağlantılı olarak example tek işaretleyici de olanak tanımaktadır. Böylece, birden fazla işaretçi eklenecekse bir KML dosyası gerekli hale gelir.

Yeni başlayanlar için basit eğiticiye here bakabilirsiniz.

İlgili konular