I have used following code to call Google Maps which is installed in Blackberry device
public void invokeGMaps(GMLocation l) {
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());
Dialog.alert("error1 " + e.getMessage());
} catch (Exception e) {
Dialog.alert("error2 " + e.getMessage());
}
}
this is working fine. I have passed current postion to it.
Suppose user will search any particular location on google maps after going on google maps. so while returning back to application i want searched location latitude & longitude from google maps.
So please give me idea how i will get it in my application from google maps application?
Please help me, or any help regarding search location on blackberry how to done it?
Thanks for reading my question patiently.
Related
I have an app with google maps link like this
const url = Platform.select({
ios: `https://www.google.com/maps/search/?api=1&query=${label}`,
android: `${scheme}${latLng}(${label})`
});
Linking.canOpenURL(url)
What I want to do is to query google maps using query=${lat},${lon} and using the name described as label above, because when I do the query, google maps open at the location but the pin displays the lat and long, and I want to display the label string
Please help!
I just figured it out. If you have google maps installed it will open the app with the desired location and pin correctly. If you don't have google maps installed it will open the browser with google maps and location! :)
const scheme = Platform.select({ ios: 'maps:0,0?q=', android: 'geo:0,0?q=' });
const latLng = `${your Lat},${your Long}`;
const label = this.state.clinic.name;
const url = Platform.select({
ios: `https://www.google.com/maps/search/?api=1&query=${label}¢er=${lat},${long}`,
android: `${scheme}${latLng}(${label})`
});
Linking.canOpenURL(url)
.then((supported) => {
if (!supported) {
browser_url =
"https://www.google.de/maps/#" +
latitude +
"," +
longitude +
"?q=" +
label;
return Linking.openURL(browser_url);
} else {
return Linking.openURL(url);
}
})
.catch((err) => console.log('error', err));
In my Ionic 3 app for Android and iOS, I need to open a specific geolocation with Google Maps (if installed) or Apple Maps. I discovered Launch Navigator which pretty much does the same.
Is there a way by which I can choose not to navigate to the specified location and only show a marker using Launch Navigator?
If not, are there any other alternatives to make this possible?
I had the same issue and this is what I came up with. There are three important steps
Check to see if the user is on iOS or Android
need to include Platform import { Platform } from 'ionic-angular';
If they are on iOS check for Google Maps
I'm using LaunchNavigator to check for the app
import { LaunchNavigator, LaunchNavigatorOptions } from '#ionic-native/launch-navigator';
Open the appropriate app with our GPS parameters
To open an external app we need the In App Browser
import { InAppBrowser } from '#ionic-native/in-app-browser';
then we have all we need to open Google Maps on iOS if it's available, with no navigation
if (this.platform.is('ios')) {
//try google maps first
this.launchNavigator.isAppAvailable(this.launchNavigator.APP.GOOGLE_MAPS).then(
response => {
if(response) {
window.open('comgooglemaps://?q=' + lat + ',' + lng + '(' + marker_name + ')', '_system');
}
else {
window.open('maps://?q=' + lat + ',' + lng, '_system');
}
},
failure => {
//check failed;
}
);
}
else if (this.platform.is('android')) {
window.open('geo://' + lat + ',' + lng + '?q=' + lat + ',' + lng + '(' + marker_name + ')', '_system');
}
Try this, it let the user to choose the app navigation (waze or map or...) to open, and add a marker on latitude and longitude given:
import { Platform } from '#ionic/angular';
...
constructor(
public platform: Platform
) {
}
public openMapsApp(lat: number, lng: number) {
const geocoords = lat + ',' + lng;
if (
this.platform.is('ios')
&& this.platform.is('iphone')
&& this.platform.is('ipad')
) {
window.open('maps://?q=' + geocoords, '_system');
return;
}
if (this.platform.is('desktop')) {
window.open('https://www.google.com/maps?q=' + geocoords);
return;
}
const label = encodeURI('7 East Street'); // encode the label!
window.open('geo:' + geocoords + '?q=' + geocoords + '(' + label + ')', '_system');
}
I have code that is used to show a device's location. It works just fine on the emulator and it takes me to the fake location at Microsoft. But it didn't work when I build it into the phone, it showed me the world map. Is this a known bug or I have done something wrong? Here is my code:
private GeoCoordinateWatcher loc = null;
private void button1_Click(object sender, RoutedEventArgs e)
{
if (loc == null)
{
loc = new GeoCoordinateWatcher(GeoPositionAccuracy.Default);
loc.StatusChanged += loc_StatusChanged;
}
if (loc.Status == GeoPositionStatus.Disabled)
{
loc.StatusChanged -= loc_StatusChanged;
MessageBox.Show("Location services must be enabled on your phone.");
return;
}
loc.Start();
}
void loc_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
{
if (e.Status == GeoPositionStatus.Ready)
{
Pushpin p = new Pushpin();
p.Template = this.Resources["pinMyLoc"] as ControlTemplate;
p.Location = loc.Position.Location;
mapControl.Items.Add(p);
map1.SetView(loc.Position.Location, 17.0);
loc.Stop();
}
}
}
Instead of using the StatusChanged event, you should use the GeoCoordinateWatcher.PositionChanged event, in from which you should use the GeoPositionChangedEventArgs.Position property, to reflect the changed location.
This is due to my location doesn't support by Bing Map. I couldn't use the Bing Map app installed in my phone neither. Hmm...
Hi i am new to blackberry application development.I want to get current gps location detail.I had successfully got the latitude and longitude but i dont know how to get the current address.can any one give me a sample?Pls thanks in advance.
What you are looking for is called "Reverse Geocoding." RIM has an example of exactly how to do this on the BB platform (well, one way to do it anyway).
You can use Google map to resolve your issue, Google map will return a JSON (or XML) according to your choice if you request with a lattitude and longitude.
The url is: http://maps.google.com/maps/geo?json&ll="+_lattitude+","+_longitude
This will return all the details of the given latitude and longitude in JSON format,And you have to parse the JSON returned by Google map.
You can use the below code:
private void getLocationFromGoogleMaps() {
try {
StreamConnection s = null;
InputStream iStream = null;
s=(StreamConnection)javax.microedition.io.Connector.open("http://maps.google.com/maps/geo?json&ll="+_lattitude+","+_longitude+getConnectionStringForGoogleMap());//&deviceside=false&ConnectionType=mds-public"
HttpConnection con = (HttpConnection)s;
con.setRequestMethod(HttpConnection.GET);
con.setRequestProperty("Content-Type", "//text");
int status = con.getResponseCode();
if (status == HttpConnection.HTTP_OK)
{
iStream=s.openInputStream();
int len=(int) con.getLength();
byte[] data = new byte[8000];
byte k;
String result="";
while((k = (byte)iStream.read()) != -1) {
result = result+(char)k;
}
try {
JSONObject jsonObjectMapData=new JSONObject(result);
JSONArray jsonaryPlaceMark = jsonObjectMapData.getJSONArray("Placemark");
JSONObject address= jsonaryPlaceMark.getJSONObject(0);
String placeName=address.getString("address");
if(placeName!=null)
lblLoc.setText(address.getString("address"));
else
lblLoc.setText("Location information currently unavilable");
} catch (Exception e) {
lblLoc.setText("location information Currently Unavilable");
}
}
}catch (Exception e) {
System.out.println(e);
lblLoc.setText("location information Currently Unavilable");
}
}
Note: I use a FacebookBlackBerrySDK-0.3.5-src to parse JSON or you can XML aslo.
I am using the following code to invoke Google map in my simulator. i have already installed Google map in my simulator.
int mh = CodeModuleManager.getModuleHandle("GoogleMaps");
if(mh > 0) {
try{
URLEncodedPostData uepd = new URLEncodedPostData(null, false);
uepd.append("action","LOCN");
uepd.append("a", "#latlon:"+lat+","+log);
uepd.append("title","Stanford University School of Medicin");
uepd.append("description", "XYZ");
String[] args = { "http://gmm/x?"+uepd.toString() };
ApplicationDescriptor ad = CodeModuleManager.getApplicationDescriptors(mh)[0];
ApplicationDescriptor ad2 = new ApplicationDescriptor(ad, args);
ApplicationManager.getApplicationManager().runApplication(ad2, true);
}catch(Exception e){
System.out.println(e+"Excepton");
}}}
but i am getting a white screen , when i am pressing the menu button RUN GMAPS option is their. but when i am pressing the RUN GMAPS then also result is same only white screen is coming. i don't why it is coming. some one please help me out
i also want to Know. how to pin multiple places in google map.
thanks in advance
i think you should use kml file.
BrowserSession visit = Browser.getDefaultSession();
visit.displayPage("http://www.geochemie.uni-bremen.de/kml/borabora.kml");
you can test on simulator also.