04-19-2011 01:41 AM
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...
Solved! Go to Solution.
04-19-2011 07:22 AM
May be try using google maps
04-19-2011 07:26 AM
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....
04-19-2011 07:56 AM
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/documenta
04-19-2011 08:16 AM
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....
04-19-2011 08:23 AM
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.
04-19-2011 08:38 AM
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
04-19-2011 08:48 AM
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/
04-19-2011 08:56 AM
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
04-19-2011 09:05 AM
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?