The iPhone supports geolocation in mobile Safari via the following call:
navigator.geolocation.getCurrentPosition(
function(pos){
var lat = pos.coords.latitude;
var long = pos.coords.longitude;
},
function(){
/* Handler if location could not be found */
}
);
I'd like to build a good list of devices that have one of the following:
support this feature out of the box, or
support this feature with an upgrade, or
support geolocation with equivalent fidelity of data with some other snippet of Javascript.
I'm only familiar with my own device, so this is my list so far:
Out of the box:
iPhone 3GS
Supported, but only with an update
iPhone 3G
iPhone 2G (?)
PC or Mac computer with Firefox 3.5
Supported with some other snippet
?
What is the level of support in Blackberry, Android phones, etc?
As of today, the W3C Geolocation API (widely associated with, though not technically part of, HTML 5) is support in the following major desktop browsers:
Firefox (since 3.5)
Safari (since 5.0)
Google Chrome (version depends on OS)
Opera (since 10.60)
Internet Explorer (since IE 9)
There are at least two mobile browsers that implement the Geolocation API:
Safari Mobile (since iPhone OS 3.0)
Android (since at least Android 1.6)
On all of these platforms, you should be able to use navigator.geolocation.getCurrentPosition, etc.
Although I think it's a great practice to standardize on the (draft, by the way) W3C Geolocation API, it's worth noting that there are a few other options in the browser, which can be particularly helpful if you need to target an older platform.
Firefox 3.1 had support for Geode, which uses calls to navigator.geolocation with very similar syntax.
Loki is a plug-in built by Skyhook which works on Internet Explorer 6, Internet Explorer 7, Firefox 2, Firefox 3, Safari and Opera. The syntax is substantially different, but still easy.
Google Gears provides a geolocation API with a syntax fairly similar to the W3C API syntax. You can install Google Gears on Internet Explorer 6+, Firefox 1.5+, Safari, Opera Mobile and IE Mobile.
From a similar more recent topic:
"I'm working on an open source library that supports all javascript location capable phones with the W3C standard. So far it supports iPhone, Android, BlackBerry and some fringe browser platforms running in a browser. The lib can also be used when writing web stack standalone apps for Nokia OVI and the Palm WebOS.
http://code.google.com/p/geo-location-javascript/"
The W3C version works on android 2.*. On android 1.6 you can fallback to gears, which will work pretty much the same way. In theory the W3C standard should also work on Firefox mobile (Fennec), which currently is available for Nokia's Maemo devices and will be standard on MeeGo.
You don’t have to have the newest mobile phone to use GPS and Geolocation API. Almost every mobile browser (without proxy server) can be used to read position from buidin GPS. If You have Java and GPS in Your phone – You can use mobile-gps-web-gate – see at http://code.google.com/p/mobile-gps-web-gate/
I know this is an old question, but you'll find a list of devices that support geolocation here: http://www.quirksmode.org/webkit.html. This list is being maintained by the site author so it should stay up to date.
Franson's GPSGate is a commercial product that can expose a Windows machine's hardware GPS to any browser through javascript. The interface is a little different from the W3C's implementation though.
Update: the Express (lite) version of GPSGate is free.
Related
I'm developing a mobile site using AngularJS (v 1.5) and it doesn't load in Opera mini. So I started searching and found one article about how Opera mini is a proxy based server and it stripes maximum JavaScript data.
But except that one article, I haven't seen it stated explicitly that Opera mini isn't supported, so I'm a bit confused.
I know Angular 2 is supposed to be released with the view of mobile-first architecture, but does Angular 1.x support opera mini?
Thanks in advance.
It seems Opera mini no longer supported by AngularJS. Check this:
https://mobiforge.com/news-comment/angularjs-to-opera-mini-youre-just-not-worth-it
Edited:
Quoting from AngularJS FAQ (latest stable v1.5):
What browsers does Angular work with?
We run our extensive test suite against the following browsers: the
latest versions of Chrome, Firefox, Safari, and Safari
for iOs, as well as Internet Explorer versions 9-11. See
Internet Explorer Compatibility for more details on supporting legacy
IE browsers.
If a browser is untested, it doesn't mean it won't work; for example, older Android (2.3.x) is supported in the sense that we avoid
the dot notation for reserved words as property names, but we don't
actively test changes against it. You can also expect browsers to work
that share a large part of their codebase with a browser we test, such
as Opera > version 12 (uses the Blink engine), or the various Firefox
derivatives.
I wrote an html5 canvas based app for plotting the electric potential as a color-map. I was using Math.log10 to re-scale the values and this worked well on quite a few systems (Chrome-Firefox-Opera; laptops and PC; Windows and Ubuntu; integrated and dedicate graphics). And then I found one PC and one laptop both with Windows where the plot would not work. The error was showing that Math.log10() could not be called as a function and just typing Math.log10 in the js console returned undefined. I got around this glitch by replacing Math.log10(someValue) with Math.log(someValue)/2.3.
So my questions are: why does this happens and are there any other similar annoying differences?
This is browser-specific. Not all browsers support the experimental Math.log10() function - the main one being Internet Explorer.
Math.log() however is a separate function which was introduced long before Math.log10(), and has much greater browser support.
The Mozilla Developer Network lists browser support for Math.log10():
Desktop Browsers
Chrome Firefox (Gecko) Internet Explorer Opera Safari
38 25 (25) Not supported 25 7.1
Mobile Browsers
Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Not supported Not supported 25.0 (25) Not supported Not supported iOS 8
Math.log10 = Math.log10 || function(x) {
return Math.log(x) * Math.LOG10E;
};
Paste this in your common JS file and this will resolve the issue if log10 will not be supported by browser.
I know it is too late, but it might help if someone will reach your post while searching.
Math.log() is the Napierian logarithm (ln).
So you should use Math.log(value)/Math.log(10)
since log10(X) = ln(X)/ln(10)
and Math.log() has much greater browser support as stated in the previous post.
Can't every mobile browsers support JavaScript? Which language/technology are used in mobile browsers pages? I mean the mobile websites...
I know XHTML is used much, What are the rest?
iPhone and default Android and BlackBerry all use WebKit. Opera and FireFox offer mobile browsers as options.
Windows Phone uses a version of IE9.
All of above support JavaScript. You can see phones from 2+ years ago that have browsers w/o JS, but they're not common anymore.
Most modern smartphones' browsers are based on Webkit - the same engine that powers Chrome and Safari. IE on Windows Phone 7 and Firefox are supposed to be standards-compliant too. Opera does have some support but don't count on it too much.
So, yes, they do support Javascript, and the technology stack is the same as for desktop ones (HTML, CSS, javascript). You even get broader support for HTML5/CSS3 in them.
Older phones, however, are a completely different story, and believe me, you don't want to go there :)
The Zepto.js website says:
Zepto.js is a minimalist JavaScript framework for mobile WebKit browsers, with a jQuery-compatible syntax.
Is it only recommended for use with apps that will be used on mobile devices or can it also be used in traditional computer browser web apps as well? What are the downsides of doing so?
I use jQuery a lot in my regular web apps (for computer browsers) and I've realized (after finding Zepto.js) that I don't always use all of jQuery's features, so Zepto.js is perfect for what I do.
Also, why is there focus on the 'WebKit' engine? Does it not work with mobile Internet Explorer on Windows Phone 7, Firefox Mobile on Android or Opera Mobile?
EDIT: The presence of $.os.android in addition to $.os.ios indicates that there is support for non-iOS platforms, so the last question is answered!
EDIT (final): I guess the real question is "Can the Zepto.js library, intended for use on mobile WebKit-based browsers, be used as a lighter-weight alternative to jQuery for the desktop also?" The answer is no.
Note: This answer is old, and not up to date anymore. Yes, Zepto started as a webkit-only, mobile-specific framework, but it has evolved since then as EBarr points out below.
So always check Zepto's website for the most up-to-date information.
Not to sound too harsh, but did you click the big button on the site to see the presentation?
You basically already answered the questions:
Yes, it's for mobile devices. Support for swipe and tap events doesn't exactly make sense on a desktop computer, where you use a mouse.
Yes, it's for WebKit specifically, because that's what's most used for mobile browsing. That means no support for IE/Firefox/Opera - mobile or desktop. As the presentation says, "No one is running IE6 on an iPhone". Most desktop-browser JS libraries exist specifically to eliminate browser differences. Zepto does the opposite.
jQuery is an offroad truck: Enormous but very capable both on- and off-road.
Zepto is a Formula-1 car: Small, fast, and built exclusively to be great on the racetrack, so it won't work right in any other situation.
It seems that Zepto's purpose has evolved. The site now notes :
Note that some optional features of Zepto specifically target mobile
browsers; as the original project goal was to specifically provide a
leaner alternative to jQuery on for the mobile web.
It lists the following as target platforms (note the inclusion of desktop browsers):
Browser support
Primary (100% support)
Safari 6+ (Mac)
Chrome 30+ (Windows, Mac, Android, iOS, Linux, Chrome OS)
Firefox 24+ (Windows, Mac, Android, Linux, Firefox OS)
iOS 5+ Safari
Android 2.3+ Browser
Internet Explorer 10+ (Windows, Windows Phone)
Secondary targets (fully or mostly supported)
iOS 3+ Safari
Chrome <30
Firefox 4+
Safari <6
Android Browser 2.2
Opera 10+
webOS 1.4.5+ Browser
BlackBerry Tablet OS 1.0.7+ Browser
Amazon Silk 1.0+
Other WebKit-based browsers/runtimes
EDIT
List above updated to reflect reality as of January 2013.
I am building a mobile site that is based on google maps, basically displays a standard google map and some markers on it. What i would like to do and haven't found and info on it, is to detect mobile devices that don't support google maps and subsequently custom markers on it, using javascript maybe?
I would really appreciate if anyone could provide an example or point me to the right direction.
Thanks in advance
EV
List of supported mobile browsers:
http://www.google.com/support/mobile/bin/answer.py?answer=39891
I had a look and I think there probably isn't an API solution that allows you to check (like GoogleMaps.supportsThisBrowser(). So I think you might just have to sniff which browser version the user is using:
http://api.jquery.com/jQuery.browser/
And then compare their browser against the above list.
The FAQ is a bit unspecific and only states:
IE 7.0+, without Compatibility mode (Windows)
Firefox 3.0+ (Windows, Mac OS X, Linux)
Safari 4+ (Mac OS X, iOS)
Chrome (Windows, Mac OS X, Linux)
Android
BlackBerry 6
Dolfin 2.0+ (Samsung Bada)
But I read somwhere else that Android prior version 2.1 and iOS prior 4.0 is not supported either. It also depends on the specific device (HTC Hero for example is very slow rendering complex maps in the browser).