I'm developing a phonegap/cordova app. Is there a way to open a phone's native navigation app within the browser view? Or is there a best practice on opening native map applications from html5 apps? Or are they all platform specific?
I've read some places that the following works for certain versions of Android
<a href="geo:some address here" />Navigate to here</a>
and that this works for iOS
Directions
I'm amazed that Phonegap hasn't implemented something like this.
You can open the native navigation app on iOS 5 (Google Maps) and iOS 6 (Apple Maps) by using the magic "maps:" protocol, e.g. window.location = "maps:daddr=50.4,-4.5"
But to launch the native Google Navigator app on Android you need to use a phonegap plugin. I wrote this one for my own purposes.
Update
The plugin has now been updated for Phonegap 3.x and supports Android, iOS and Windows Phone, including an option to prefer Google Maps on iOS.
The plugin is here: https://github.com/dpa99c/phonegap-launch-navigator
The plugin is great! Thanks for sharing!
I tried it in my app but unfortunately I have Phonegap version 3.x and your plugin is only working for Phonegap 2.x :(
So in order to get it working on Phonegap 3.x I got the plugin from your github repo and made some changes so that it works for 3.x
The modified PhoneNavigator Plugin for Phonegap 3.x can be downloaded from my github repo:
https://github.com/viktor0710/PhoneNavigator-Phonegap-3.x.git
How to integrate it in your Phonegap 3.x project:
Open a console window
Go to your Phonegap app root
Then execute: phonegap local plugin add https://github.com/viktor0710/PhoneNavigator-Phonegap-3.x.git
Copy "phonenavigator.js" from the repo (www/phonenavigator.js) in your app (ex: yourapp/www)
include "phonenavigator.js" in you app:
Copy "cordova.js" from the repo (www/cordova.js) in your app (ex: yourapp/www)
include "cordova.js" in you app:
How to use it:
//function declaration
function navigateTo (lat, lon, successFn, errorFn) {
cordova.require('cordova/plugin/phonenavigator').doNavigate(lat, lon, successFn, errorFn);
}
//set lat and lon variables. Most probably read them from the UI
var latitude = 48.137607;
var longitude = 11.568569;
//call function
navigateTo(
latitude,
longitude,
function(){
console.log("Successfully opened navigator");
},
function(){
console.log("Error opening navigator");
}
);
As mentioned above, the following works on Galaxy S4 Android (just tested it), to bring up the Google Maps/Navigation app and waze:
Wikimedia Headquarters
Credit: http://en.wikipedia.org/wiki/Geo_URI#Example
Please also see the answer here: https://stackoverflow.com/a/19765368/2728686
For the record, if someone find this thread by looking on Google like I did, it worked for me directly, working with Ionic framework, by doing two things :
In the myapp.config(...) of your app add
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|geo):/);
(dont forget to add $compileProvider as a dependency)
In the config.xml, add the line
<access origin="geo:*" launch-external="yes"/>
That's all.
Cordova 3.6.0 introduces a second whitelist, for restricting which URLs are allowed to launch external applications. In previous versions of Cordova, all non-http URLs, such as mailto:, geo:, sms: and intent, were implicitly allowed to be the target of an a tag. Because of the potential for an application to leak information, if an XSS vulnerability allows an attacker to construct arbitrary links, these URLs must be whitelisted as well, starting in Cordova 3.6.0.
Cordova 3.6.0 Whitelist Guide
So you need to add explicitly in the config.xml:
<access origin="tel:*" launch-external="yes" />
<access origin="mailto:*" launch-external="yes" />
Related
I have to be missing something:
I installed node.js, installed react-360, created the Hello360 app but can't get the page to go into VR Mode in my Oculus Quest via the Oculus Browser. It just looks the same as it does on a PC.
After googling for a while found a note that said it only works with https so I got that working and ... nope no VR.
Under Windows 10 Professional.
React 360 uses the WebVR API. Oculus Browser removed support for WebVR in version 9. This is why it's not entering VR.
The replacement for WebVR is WebXR. You might want to pick up a different library which supports WebXR, like AFrame.
immersiveweb.dev has some links to other frameworks (yes, including React 360, but that link is a 404 :P). Or you could go bare-handed with the WebXR API directly.
It looks like the live React-based project right now is https://github.com/pmndrs/react-xr based on https://github.com/pmndrs/react-three-fiber
I used Phonegap as the basic framework to built my IOS project. In order to write a native function, I wrote a plugin and wanna to used objc to create a new view. However, I failed to create it. What should I do next?
You need to read and understand Cordova plugins to bridge between native code and Phonegap HTML5
This is the Map/Earth Integration example at Google's 'Code Playground' site:
https://code.google.com/apis/ajax/playground/#maps/earth_integration
I can run that example from the playground just fine. But if I save its html locally and then try to load that file in Chrome, the browser just stalls indefinitely with:
Installed Plugin Version: Loading...
An Android app of mine that attempts to load the same example into a WebView does the same thing. That app works fine when running html that employs the API V3 javascript.
The Chrome browser's Developer Tools debugger stops on line 15:
"google.load("maps", "2.x");"
saying that "google" is not defined. It also reports that 'GMap2' (line 18) and
"GET file://www.google.com/jsapi?key=ABQetc" (line 10) are also not defined.
The Map/Earth Integration example html includes a (long) jsapi key. Do I need to get my own jsapi key maybe? Where do I get one? I have a v2.API_KEY from:
"https://console.developers.google.com/project/apps~elite-rider-459/apiui/credential"
but I'm not sure if it will work with Google Earth and Google Earth is not among the available choices at the "APIs % auth" page at that console website:
I remember reading that Google Earth no longer requires such a key. Can anyone tell me
what I'm missing? And how to stop Google Earth from embedding itself in my desktop? I tried removing and reinstalling the plug-in, but GE continues to do so.
Thanks,
Ted
When you run this example from local filesystem you must prepend the http: -protocol to the <script/>-src , otherwise the browser will try to load the API from your filesystem(what of course will fail)
When I ran "Marker V3" code example in Google's Code Playground under "Maps V3" section, on local file, the code didn't execute. I had to add "http:" to script tag that loads Google maps in order to run the code locally.
I'm currently trying to make the HTML5 viewer.js example work inside an android WebView.
WebView initialization looks like this:
webView.setWebViewClient(new WebViewClient());
final WebSettings webSettings = webView.getSettings();
settings.setJavaScriptEnabled(true);
webView.loadUrl("file:///android_asset/index.html");
The thing is that in a Nexus 7 running Android 4.3 JB (which uses Chrome as stock browser) the example fails and renders: Error loading document metadata (did you check the url?). I also tried a Samsung Galaxy Nexus running 4.2 with same results.
But on a GBox (MediaBox, Android TV) running Android 4.0.4 ICS (which uses the default Browser application), it takes a while but it renders the document. With a lot of styles problems, but it can render it.
However, if I serve all the assets from a remote server (for instance, a Python SimpleHttpServer) and load the WebView using the index page url, it doesn't have any problems in any device.
Is this a Crocodoc View API specific issue regarding cross-browsing?
This is a Chrome-specific issue, see here: Problems with jQuery getJSON using local files in Chrome
In summary, Chrome's security model blocks AJAX requests from file:/// URLs. This causes trouble for viewer.js because it utilizes AJAX to load resources in a performance optimized manner. The recommended solution is to always serve the assets through a web server.
I have downloaded sancha touch-charts.If i want to host in my local host,I have to install sencha touch? will sencha-charts work without sencha-touch? how can I configure both in webserver?because sencha-charts is add-on of sencha-touch?
Yes, Touch Charts is an addon for Sencha Touch and requires you load sencha-touch.js before loading touch-charts.js. When you download the Touch Charts beta, Sencha Touch is included in the download and the examples provide everything you need to get started.