Thursday, 5 July 2012

GOOGLE MAPS ON BLACKBERRY APP

There is no library for Google Maps on blackberry. As my research have 3 options
 1.   Send some data to the Google Maps app and then have it launch/run on its own.
 2.  Sign up for a Google Maps Premier account and use the Static Maps API.
 3. Completely roll your own (I'm guessing this may need a Google Maps Premier account as
          well).
4. Use Blackberry maps(Its not supports @INDIA)
                           Android Google Maps Vs Blackberry Google Maps  
            Android                                                Blackberry
1.Supprots Places API                                    1. Directions
2. Directions.                                                  2. Layers
3. Layers                                                             a.Traffic                                       
   a. Restaurants                                                  b.Satellite                                    
   b. Traffic                                                         c. Terrain            
   c. Satellite view                                              d.Latitude                       
   d. Terrain                                                        e. Driving Directions                       
   e. Transit Lines                                               f.Transit Lines
   f. Latitude                                                       g. My Maps 
   g. My Maps                                                                   
   h. Driving directions 
                                      
                     Blackberry Google maps Issues:
1. not getting current location.(GPS not working).
2. Sign in not happening - login failed. (Google maps gives extra features after
account login).
3. Maps only work on Blackberry data plan.
4. Application must have signing.(Because application using secure api).

Google Maps Usage:
Invoking google maps opens currenlty active instance of google map
Function:
CodeModuleManager is invoke active (Already installed) google maps api
/**********************Example **************************************/
public void invokeGMaps(GMLocation l) {
    int mh = CodeModuleManager.getModuleHandle("GoogleMaps");
    if (mh == 0) {
        try {
           BrowserSession visit = Browser.getDefaultSession();
           visit.displayPage("http://m.google.com/maps"); 
   throw new ApplicationManagerException("GoogleMaps isn't installed");
           } catch (ApplicationManagerException e) {
            System.out.println(e.getMessage());
           }
          }
          RichTextField rich = new RichTextField("fhfdjdytdytd"+ mh);
          add(rich);
          URLEncodedPostData uepd = new URLEncodedPostData(null, false);
          uepd.append("action", "LOCN");
          uepd.append("a", "@latlon:" + l.getLatitude()
           + "," + l.getLongitude());
          uepd.append("title", l.getName());
          uepd.append("description", l.getDescription());
        String[] args = { "http://gmm/x?" + uepd.toString() };
          RichTextField rich1 = new RichTextField("l.getName()"+ l.getName());
          add(rich1);
          ApplicationDescriptor ad = CodeModuleManager
            .getApplicationDescriptors(mh)[0];
          ApplicationDescriptor ad2 = new ApplicationDescriptor(ad, args);
          try {
           ApplicationManager.getApplicationManager()
             .runApplication(ad2, true);
          } catch (ApplicationManagerException e) {
           System.out.println(e.getMessage());
          }
         }
/**************************Function end******************************/
Usage:
class MyScreen extends MainScreen{
 public MyScreen(){
     GMLocation location  = new GMLocation(-80.5207,43.4631, "JayaNagar");
      invokeGMaps(location);
}
/***************GMLocation is a model class ***************************/
public class GMLocation {   
     String mName;
     String mDescription;
     double mLatitude;
     double mLongitude;
     public GMLocation(double lat, double lon) {
      mLatitude = lat;
      mLongitude = lon;
     }   
     public GMLocation(double d, double e, String name) {
      this(d, e);
      mName = name;
     }   
     public GMLocation(double lat, double lon, String name, String descr) {
      this(lat, lon, name);
      mDescription = descr;
     }   
     public String getName() {
      return mName;
     }   
     public String getDescription() {
      return mDescription;
     }   
     public String getLongitude() {
      return String.valueOf(mLongitude);
     }   
     public String getLatitude() {
      return String.valueOf(mLatitude);
     }
    }
/***************GMLocation Ends***************************************/

 

No comments:

Post a Comment