Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
kiran_b
Posts: 260
Registered: ‎10-27-2010
My Device: 8520
Accepted Solution

Reg;Invoking maps in blackberry

Hi,

 

     In my application i want to invoke maps , for that i am using mapview and everything is fine.but sadly i heard that blackberry maps supports only some countries..

 

    in my app i want to show counties like India,Afganisthan etc.. those are not supported by blackberry maps..

 

so please any one suggest me how can i get these countires also if i select it in my application.it's very urgent for me pls give me reply ASAP..

 

     i am using jde 4.7 for my application...

Please use plain text.
Developer
sheeluwiki
Posts: 254
Registered: ‎03-15-2011
My Device: simulator
My Carrier: simulator

Re: Reg;Invoking maps in blackberry

May be try using google maps

------------------------------------------------------------------------------------------------
Click "Accept as Solution" if post was what you needed. Give kudos if you feel response is helpful.

Please use plain text.
Developer
kiran_b
Posts: 260
Registered: ‎10-27-2010
My Device: 8520

Re: Reg;Invoking maps in blackberry

Hi,

 

  While googling i understand that google maps is only my solution..

 

but i dont know how to start it, will you please give me a snippet for how to invoke google map in application through code..

 

or atleast tell me the steps for accessing google maps...

 

i am waiting for reply....

Please use plain text.
Developer
sheeluwiki
Posts: 254
Registered: ‎03-15-2011
My Device: simulator
My Carrier: simulator

Re: Reg;Invoking maps in blackberry

Here is the sample code snippet which works fine for me.

 

Using this code you can display single location on the map.

 

class GoogleSingleLocation_Scr extends MainScreen {
 public GoogleSingleLocation_Scr() {    
 }    
 protected void makeMenu(Menu menu, int instance) {
  super.makeMenu(menu, instance);
  menu.add(mInvokeGMaps);
 }    
 MenuItem mInvokeGMaps = new MenuItem("Run GMaps", 0, 0) {
  public void run() {
   GMLocation location 
    = new GMLocation(51.507778, -0.128056, "London");
   invokeGMaps(location);
  };
 };    
 public void invokeGMaps(GMLocation l) {
  int mh = CodeModuleManager.getModuleHandle("GoogleMaps");
  if (mh == 0) {
   try {
    throw new ApplicationManagerException(
      "GoogleMaps isn't installed");
   } catch (ApplicationManagerException e) {
    System.out.println(e.getMessage());
   }
  }
  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() };
  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());
  }
 }
}

 

 

Suppose if you need to display multiple location on google maps then you need to prepare a KML file and make it available on public server which google map can access

 

Some URL links which might be useful for you.

 

http://code.google.com/intl/en/apis/maps/documentation/mapsdata/developers_guide_java.html#Audience

 

http://stackoverflow.com/questions/3301378/google-maps-apidynamic-plot-multiple-locations-via-url-sh...

 

 

------------------------------------------------------------------------------------------------
Click "Accept as Solution" if post was what you needed. Give kudos if you feel response is helpful.

Please use plain text.
Developer
kiran_b
Posts: 260
Registered: ‎10-27-2010
My Device: 8520

Re: Reg;Invoking maps in blackberry

Hi,

 

 

     Tnaks for reply, where can i get jar file accessing 


GMLocation class will you please give me the link for this..

appreciate your help....
Please use plain text.
Developer
sheeluwiki
Posts: 254
Registered: ‎03-15-2011
My Device: simulator
My Carrier: simulator

Re: Reg;Invoking maps in blackberry

Here is the code for GMLocation

 

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

 

 

You do not need any other external jar files to access google maps in BB.

------------------------------------------------------------------------------------------------
Click "Accept as Solution" if post was what you needed. Give kudos if you feel response is helpful.

Please use plain text.
Developer
kiran_b
Posts: 260
Registered: ‎10-27-2010
My Device: 8520

Re: Reg;Invoking maps in blackberry

Hi,

 

    I am getting null pointer exception when i select  'Run Gmaps 'menu item and nothing is displayed...

while debugging i found that in below line i am getting null pointer acception

  ApplicationDescriptor ad = CodeModuleManager
    .getApplicationDescriptors(mh)[0];

 

help needed

Please use plain text.
Developer
sheeluwiki
Posts: 254
Registered: ‎03-15-2011
My Device: simulator
My Carrier: simulator

Re: Reg;Invoking maps in blackberry

Have you installed Google Maps application in your device / Simulator?

 

If you have not installed it yet, install it and try again.

 

http://www.google.com/mobile/maps/

------------------------------------------------------------------------------------------------
Click "Accept as Solution" if post was what you needed. Give kudos if you feel response is helpful.

Please use plain text.
Developer
kiran_b
Posts: 260
Registered: ‎10-27-2010
My Device: 8520

Re: Reg;Invoking maps in blackberry

Hi,

 

   I haven't install google maps on Blackberry , i tried but not succeed ..

 

let me clarify is there any chance to install google maps programatically ???

 

why because if i release my application to client ,how can we know whether he installed google maps or not...

 

if he is not installed then application doesnt work thats why i am asking above question

Please use plain text.
Developer
sheeluwiki
Posts: 254
Registered: ‎03-15-2011
My Device: simulator
My Carrier: simulator

Re: Reg;Invoking maps in blackberry

Try the below URL in you device or simulator and download the google map.

 

m.google.com/maps

 

 

What is the problem you are getting in downloading the map into the device?

------------------------------------------------------------------------------------------------
Click "Accept as Solution" if post was what you needed. Give kudos if you feel response is helpful.

Please use plain text.