Quelqu'un peut-il me dire comment utiliser Google Maps dans le développement d'applications Blackberry au lieu de la carte Blackberry?Utiliser Google Map dans l'application Blackberry
Répondre
Récemment, j'ai eu une idée pour utiliser Google Maps website de Browser.Field mais ce n'est pas possible puisque GMaps sont basés sur JavaScript et qu'il est mal supporté par le navigateur natif Blackberry.
En fait, il y a 2 façons d'utiliser Google Maps sur Blackberry:
- installons Google Maps Mobile application (voir example of use)
- utilisation Google Static Maps API pour générer et envoyer l'image sur demande de l'appareil. Cela nécessite la mise en œuvre côté serveur et Sign Up for the Google Maps API
Voici un petit exemple:
Le formulaire pour afficher l'image statique Google Maps:
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);
}
}
}
La classe INET de classe pour télécharger la statique image:
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());
}
}
}
}
L'action Button qui lance le téléchargement et l'action de rappel qui charge le formulaire pour voir l'image
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();
}
}
Affinez et éditez le code afin qu'il corresponde à vos besoins. Il m'a fallu du temps pour bien faire les choses.
Il est maintenant possible d'utiliser Google Maps au lieu de cartes BlackBerry avec nos propres données comme dans l'image.
Si vous souhaitez utiliser google maps pour afficher vos propres emplacements/marqueurs, vous pouvez utiliser google maps en utilisant ApplicationDescriptor
depuis votre application. Vérifiez les cartes google sur l'appareil en utilisant CodeModuleManager.getModuleHandle("GoogleMaps");
il renvoie un entier où non nul signifie qu'il est disponible. Ensuite, vous pouvez ajouter des emplacements dans votre fichier KML
, vous pouvez même personnaliser les pointeurs d'emplacement en utilisant des balises de fichier KML.
Le example comme liée par Max permet à un seul seul marqueur. Un fichier KML devient donc nécessaire si plusieurs marqueurs doivent être ajoutés.
Vous pouvez regarder le tutoriel simple here pour les débutants.
- 1. dans Google map
- 2. Comment utiliser google map pour mon site?
- 3. comment intégrer google map?
- 4. get link dans google map info box
- 5. intégrer google map dans le contrôle wpf
- 6. Charger Google Map dans l'application iPhone
- 7. Google Map - Prendre des coordonnées
- 8. Thickbox -> IE8 -> Google Map Problème
- 9. Google map + jQuery: bug de rendu
- 10. marqueurs multiples sur une carte Google Map
- 11. Google Map InfoWindow est trop large
- 12. Correctement dimensionnement de Google Map dans un DIV en pourcentage
- 13. Charger Google Map directement à l'adresse spécifiée dans l'iPhone
- 14. Afficher certaine InfoWindow dans Google Map API V3
- 15. chargement google map dans les problèmes div ajax: -/- jquery
- 16. API Google Map vs MS Earth Earth API
- 17. Map Application dans iphone
- 18. Quelle devrait être la clé google map api?
- 19. obtenir l'état de la ville de google map
- 20. comment trouver la distance entre 2 points sur google map?
- 21. Ruby sur rails gem pour l'intégration google map
- 22. Comment puis-je HYPERLINK une cellule Excel vers Google Map
- 23. Projeter seulement une partie de SVG sur Google Map
- 24. Google Map API v3 - Définir les limites et le centre
- 25. Quel événement est déclenché lorsque Google Map repeint?
- 26. Est-ce que Calculatedistance javascript de google map exact?
- 27. [iPhone] dessiner le cercle autour d'un emplacement sur google map
- 28. exemple sur l'utilisation de google map v3 + gwt par jsni
- 29. Accéder à Google Map Listing à partir de GData
- 30. Centre Google Map Basé sur l'adresse IP géocodée