Determining the location of mobile web site user - mobile

Is there anyway to track the location (as precise as possible) of a user of a mobile web site?
I am aware that the best way to locate someone is via GPS, but I'm not sure if that is possible through a mobile web site? I also know that you can roughly track a users location via the device's IP address, but I'm not sure if this is the best method?
Looking at Google Maps as an example, the Google Maps website can track my current location pretty much precisely using an iPhone or an Android device. Is this because these sites are activating the device's GPS capabilities, or is there something else going on in order for them to achieve this?
The website I am planning to create will ideally be capable of running on Smartphone devices (such as Android/iPhone/Blackberry/Windows Phone etc), but also be capable of running on non-smartphone devices, which may not have GPS technology built in to query the current location.
Can anyone suggest the best way this could be achieved please? I know that some existing location libraries such as GeoLocation are widely recommended, but again, are these compatible with devices which don't necessarily have GPS technology available?
Thanks in advance.

You can use the HTML5 Geolocation API on devices that support it. It will return the most accurate location that is available which might be A-GPS or wifi location.
See for example this tutorial on how to use geolocation with JavaScript.
Basically you test for geolocation support and request the position:
if (navigator.geolocation) { // device can return its location
navigator.geolocation.getCurrentPosition(function(position) {
console.log(position.coords.latitude);
console.log(position.coords.longitude);
});
}
Please note, that this code will prompt the user if they want to share their current location or not.

Related

Any alternative to Google Maps API with directions from current location?

I am currently developing a web site for my thesis which features my City's tourist spots (e.g. malls, parks, restaurants) with Google Maps API that shows the current location of the user and the destination point and all the possible routes to said destination. But sadly, with the Billing system I am limited to load a few maps before it says "OVER_QUERY_LIMIT".
I have researched few free Maps API and I have found some, like MapBox, HERE Api... What would be the best free alternative for Google Map API?
P.s. I am still a student and can not afford to pay $200. If there are any other possible ways in handling this, please do let me know. Thank you!
Check Freemium Plan from HERE Maps, 250.000 transactions/months for free, no need for credit card.
You can use JS, REST and Native APIs.

Is it possible to allow users to search for an address, and attach a pin to a location like in Google Maps using Leaflet? How do I do this?

I've read about how some sites use streets data and overlay it over their map tiles. Is this necessary in leaflet? I think the attaching of a marker is fairly well-covered in the Leaflet documentation, but I'm not sure whether there's a (ideally reasonably easy) way to give it the full search for address functionality in Google Maps.
Should be possible - you'll need a geocoding web service, like Google's, that you can hand an address and will give you back a lat/lon coordinate, which you can then plot onto Leaflet. I believe MapQuest has a free one; not sure if there's an API limit or anything along those lines: http://www.mapquestapi.com/geocoding/
In fact, I think this template site from MapBox, though it doesn't use Leaflet, hooks into MapQuest for it's geocoding. You might be able to use that as an example.
MapQuest offers two Geocoding Web Services, which will take an address and convert it to latitude and longitude coordinates.
MapQuest Geocoding Web Service (licensed data, meaning, the 'behind the scenes' geocoding data is commercially-available data)
MapQuest Open Geocoding Web Service (open data, meaning, the 'behind the scenes' data is open, generated by users of the OpenStreetMap community).
The Open Geocoding Web Service is brand new! For more information, check out the MapQuest Developer Network and Developer Network Forums.

Is it possible to deliver digital content to a user's google drive account?

Without using Google Checkout, I would like to provide a link that allows a user to download digital content directly to their Google Drive account. Does anyone have advice on how this might achieved?
We have our own shopping cart system and host my own content.
We simply wish to provide a link to our content that transfers the digital content to the location of the consumer's choosing.
--Charles
We currently don't provide such widgets for web developers. You can however use the REST API to accomplish such a thing.
Please refer to the Drive API Documentation for how to do it server-side. For a client-side application (full JavaScript), you can refer to the StackOverflow answer.
The Drive SDK currently requires applications to be installed in a user's account through the Chrome Web Store; we are actively working on making the story better for users and developers so stay tuned!

Port Web Scraper/ Web Crawler over to a Mobile Device?

Is it possible to port a web scraper/web crawler over to a mobile device such as a smart phone? If so, how would I do it?
I feel like this is a loaded question... of course it is possible, but why would you want to?
If so, how would I do it?
Well, you would take an existing web crawler and port it. As a matter of fact, you might not have to do much porting: if you take a crawler like Nutch, it's already written in Java, it's available to download as a package so you can just drop it in your android phone, get root access and run the crawler. But again: why would you want to do it?
Whatever your goal is, I would think that putting a web crawler on a smart phone would be an overkill. So what's your goal?

Need to limit access to a mobile website to specific registered mobile devices

I've researched a ton and can't seem to find a solution for how to limit access to a secure mobile website to ONLY PREVIOUSLY REGISTERED devices.
I already have a secure login in-place, but we must also insure that ONLY registered devices access the site. We cannot have users sharing login information with others and allowing others to login and use the protected information.
Is there anyway to do this?
I've looked at trying to acquire the devices MAC address using JavaScript, PHP, or something similar, but this doesn't seem to be an option.
MAC addresses can be spoofed, so use something else such as REST-based authentication.
You can't do that because websites usually register users as opposed to their mobile devices as nothing can be truly unique about a physical device but the information it carries. The proper way of doing client based (as opposed to user based) authentication is to use a client certificate.
If you just want to simplify the sign-in experience for your users on mobile device you may want to take a look at this.

Resources