Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Current Location View modes: 
User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 12/4/2012 8:30:48 AM
   
Current Location
How would one capture a viewers current location? JavaScript? I thought there was a webpart for this, although unable to find it.

User avatar
Kentico Support
Kentico Support
kentico_janh - 12/5/2012 6:12:29 AM
   
RE:Current Location
Hello,

What kind of location do you mean? It suppose to be a geolocation of a user of a location on a page? Or a different location?

Best regards,
Jan Hermann

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 12/5/2012 6:19:50 AM
   
RE:Current Location
Geo location.

User avatar
Kentico Support
Kentico Support
kentico_janh - 12/7/2012 2:19:50 AM
   
RE:Current Location
Hello,

There is no web part for this, however there is very simple API for this, so you can write your own macro as below:
case "location":
e.Match = true;
CMS.WebAnalytics.GeoLocation gl = CMS.WebAnalytics.GeoIPHelper.GetLocationByIp("195.80.23.15");
e.Result = gl.CountryCode/Latitude/Longitude/etc.;
break;

Best regards,
Jan Hermann

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 12/10/2012 12:18:43 PM
   
RE:Current Location
Thanks Jan. This will help somewhat with a desktop user although some users IP could be hundreds or thousands of miles away from their actual location and may not be very accurate.

How about a mobile user? How can I get their location from the GPS on their phone?

User avatar
Kentico Support
Kentico Support
kentico_janh - 12/12/2012 3:56:13 AM
   
RE:Current Location
Hello,

Regrettably no. I have consulted it with our development department and they told me, we can just recognize a mobile device (its type, screen resolution, etc.), but not the location according to wi-fi, GPS or BTS positions.

Best regards,
Jan Hermann

User avatar
Member
Member
mosgath - 12/17/2012 1:27:32 PM
   
RE:Current Location
Javascript and HTML5 has some capabilities for geo location and accessing it from a Mobile GPS if the browser supports it and the user allows it. I haven't used specifically, but found it documented in many places. Search on "navigator.geolocation" and you should see some different examples. The w3schools.com has some decent documentation on it:
"Internet Explorer 9, Firefox, Chrome, Safari and Opera support Geolocation.

Note: Geolocation is much more accurate for devices with GPS, like iPhone."

User avatar
Member
Member
jiris-kentico - 12/30/2012 3:27:47 AM
   
RE:Current Location
Hi,
as kentico_janh said, we do not have support for geolocation, but I believe that it would not be that hard to implement your own solution (e.g. your own webpart). I would like to just add link to HTML5 Geolocation API . As you can see the API is pretty easy to use and there is plenty of online APIs to use to get more user friendly data than latitude and longitude is (e.g. map, address, street).

Also please consider that HTML5 Geolocation is rather new feature, so older browsers might not support it, so please do not forget that you still should provide some fallback option for users of old browsers. Other thing I would like to warn you about is that user must give his consent to use HTML5 Geolocation. What I want to say is that HTML5 Geolocation is neat API and it can simplify things a lot, but if you are building some key feature on your web, you should not rely solely on it.

Since HTML5 Geolocation API can be used for many purposes I would like to ask you to give us some further information about what you want to achieve and post it on our uservoice so we can consider your request and implement it, or at least give your better support for your solution.

User avatar
Member
Member
egarrison-wte - 12/30/2012 8:46:52 AM
   
RE:Current Location
You may want to look at this Link also. I tested from current Firefox & Chrome (On Macbook) over Verizon MiFi 4G card. They were off by 300 miles. At the local Starbucks, they were dead accurate.

http://www.c-sharpcorner.com/UploadFile/b19d5a/geolocation-in-html5-using-Asp-Net/