Rails 5: Omniauth with devise and html5 geolocation issue

I’m using devise and I have just added the omniauth feature to a rails app.

gem 'omniauth-facebook' gem 'omniauth-twitter' gem 'activerecord-session_store' 

routes

devise_for :users, controllers: {registrations: 'users/registrations', sessions: 'users/sessions', omniauth_callbacks: "users/omniauth_callbacks"} 

devise.rb

config.omniauth :facebook, 'App id', 'App_secret', callback_url: "https://localhost:3000/users/auth/facebook/callback", :scope => 'email', info_fields: 'email, name' config.omniauth :twitter, 'app_id', 'App_secret', callback_url: "https://localhost:3000/users/auth/twitter/callback" 

User.rb

devise :database_authenticatable, :registerable, :recoverable, :timeoutable, :rememberable,      :validatable, :trackable, :lockable, :omniauthable, :omniauth_providers => [:facebook, :twitter], :authentication_keys => {email: true}    def self.create_from_facebook_data(facebook_data)     where(provider: facebook_data.provider, uid: facebook_data.uid).first_or_create do | user |       user.email = facebook_data.info.email       user.name = facebook_data.info.name       user.image = facebook_data.info.image       user.password = Devise.friendly_token[0, 20]     end   end    def self.create_from_twitter_data(twitter_data)     where(provider: twitter_data.provider, uid: twitter_data.uid).first_or_create do | user |       user.email = twitter_data.info.email       user.name = twitter_data.info.nickname       user.image = twitter_data.info.image       user.password = Devise.friendly_token[0, 20]     end   end 

omniauth_callbacks_controller.rb

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController   # facebook callback   def facebook     @user = User.create_from_facebook_data(request.env['omniauth.auth'])     if @user.persisted?       sign_in_and_redirect @user       set_flash_message(:notice, :success, kind: 'Facebook') if is_navigational_format?     else       flash[:error] = 'There was a problem signing you in through Facebook. Please register or try signing in later.'       redirect_to new_user_registration_url     end   end    # twitter callback   def twitter     @user = User.create_from_twitter_data(request.env['omniauth.auth'])     if @user.persisted?       sign_in_and_redirect @user       set_flash_message(:notice, :success, kind: 'Twitter') if is_navigational_format?     else       flash[:error] = 'There was a problem signing you in through Twitter. Please register or try signing in later.'       redirect_to new_user_registration_url     end   end    def failure     flash[:error] = 'There was a problem signing you in. Please register or try signing in later.'     redirect_to new_user_registration_url   end end 

I can login using a social media account and everything is working just fine up to this point, but I have noticed a bug that I can’t figure out what is causing it.

I’m using the html5 geolocation in order to get the location of a user and then according to that location conduct a search. Also, in order to use and allow access to the html5 geolocation I had to implemented this.

function getLocation() {     if (navigator.geolocation) {         navigator.geolocation.getCurrentPosition(setGeoCookie, displayError);      } else {         alert("Geolocation is not supported by this browser.");     } }  function setGeoCookie(position) {     var cookieName = "lat_lng";     var now = new Date();     var time = now.getTime();     time += 3600 * 5000;     now.setTime(time);     var cookie_val = position.coords.latitude + "|" + position.coords.longitude;     document.cookie = cookieName +"=" + cookie_val + '; expires=' + now.toUTCString() + '; path=/';     $  ("#search-form").trigger('submit.rails'); }  function displayError(error) {     var errors = {         1: 'You need to click on allow.',         2: 'Position unavailable',         3: 'Request timeout'     };     alert("Error: " + errors[error.code]);     location.reload(); } 

Now when I try to test while in a localhost and using a safari browser this weird thing happens… I can login with a social media account but the error 2: 'Position unavailable' pops up when I try to implement a search. This problem only happens when I’m using safari, if I use firefox it works just fine.

Any ideas what might be causing this issue in safari and a localhost and how I can solve it?

SharePoint Online Multi Geo SPAppWebUrl is not updated after moving site to a new geolocation

I am developing a provider hosted app on SharePoint Online. I move my site which has my app installed to a different geo location (eg: from US to Japan), I notice that the app is also moved to the new location. However, when I load my app in the new location, I notice that the SPAppWebUrl is the URL of the old location. Is there anything I can do for the SPAppWebUrl to use the new location? My aspx pages are being fetched from the old location therefore it returns 404 Not Found

Incorrect display of the language by user geolocation in Google maps

Good day. I could not find an answer to this question and I want to know what the experts know about this problem. I created a google map with tags in Greece, put it on my website and asked website users from different countries to see what language they see the google map with tags. – from Germany see the English text – from England see the Russian text – from Ukraine see the Russian text – from Ukraine see the English text

Since the site is international, I expected that Google maps would determine the user’s geo-location and show him the map in his language. But now this is a problem, as people see the completely different language of city names, inconsistent with their location. Website users mostly speak English. And, of course, in other languages. But Russian is definitely not included in the priority list, so I don’t want to be seen by users who do not know it. How is this problem solved? Has anyone already solved this problem? Does this problem have a solution or is it not possible yet? I do not understand how to solve it. In Google maps I was sent to ask all the technical questions on this site. I hope that Google technical support will answer me or users who are aware of such a problem and can solve it or suggest whether this problem has a solution.

Nginx geolocation / site redirection

so we’ve set up our nginx to redirect everytime a user browses our site, now we have a downloadable app on the site, in which after users downloads the app they will be redirected to a “thank you page” /thankyou/page/ to be specific.

Problem is, I have 3 locations to test, Germany, UK, and France, after installing (its a chrome extension) / downloading the app, it does not redirect to the thank you page we set up.

what we expect is “.co.uk/thankyou/page/” for UK page for example, instead it redirects to “.com/thankyou/page/”

Please note, we can already redirect the pages when typing in www.example.com (.co.uk, .de, .fr) also when manually typing/adding in /thankyou/page/, what we want to do is re-direct it using nginx geolocation when the app gets installed. Thanks!

Matching a GeoLocation from to nearest GeoJSON LineString

We have a standard GeoJSON dataset containing a featureCollection of LineStrings. What would now be the most efficient system to use that can take location coordinates as input and return the nearest Feature from our dataset?

It’s a snap to roads excercise but we want to use our own dataset.

Dataset example:

{       "type": "Feature",       "properties": {         "@id": "way/5209753",         "bicycle": "yes",         "cycleway": "opposite",         "highway": "residential",         "maxspeed": "30",         "name": "Paul Fredericqstraat",         "oneway": "yes",         "oneway:bicycle": "no"       },       "geometry": {         "type": "LineString",         "coordinates": [           [             3.7134021,             51.0402841           ],           [             3.7133769,             51.0403228           ],           [             3.7115418,             51.041733           ],           [             3.7109067,             51.0422433           ],           [             3.7108158,             51.0422903           ],           [             3.7107692,             51.0423121           ],           [             3.7107566,             51.042318           ]         ]       },       "id": "way/5209753"     }, ``` 

Is Forgotten Realms geo-location data copyrighted, or free to use?

I am in the process of creating a gis map of Toril, starting from the Faerun Continent. (More details are in this question on GIS.SE: Starting a QGIS project for a fantasy world map from raster images.)

One commenter asked if I could share this on Google Earth; however, I have no idea of the legal restrictions on using this material.

Let’s say I create a Faerun map completely from scratch; it would be based on copyrighted material, which will be used only as reference and will not be republished in the final work, but obviously I will put in my maps everything related to mapping. Can I distribute it freely?

For example, I want to place Phandelver on the map, so I’ll start gathering everything geo-related from the adventure book, scan it, and retrace it all in QGIS (the geographic information system software I am using), I will not include any of the published maps in the final result.

The final result would be a browsable and zoomable Google-Earth-like map.

In the scope of what I want to do, I think the larger question is: Are Toril, Faerun, and all of the Forgotten Realms geographic information free to use?

Specifically, are the geographic coordinates of mountains, rivers, hills, roads, cities (and the size and shape of the buildings, monuments and roads in them) under copyright?

How to Send Geolocation info to Server using PHP?

I am trying to access geolocation using javascript then send it to server using PHP.I am using xmlhttp.open(),xmlhttp.send() as well as jQuery.ajax or $ .ajax function but none of them seemed to work. Should I create a tag to send location using GET ? My code is the following:

<!DOCTYPE html> <html><body> <h1>Click the following button to share your location!</h1><br> <button onclick="getLoc();">Share!</button> <script>     function getLoc()     {         navigator.geolocation.getCurrentPosition(success,error,option);     }     function success(pos)     {         var lat=pos.coords.latitude;         var lng=pos.coords.longitude;         $  .ajax({             type: "GET",              url:  "loc.php",              data:{ "q1" : "lat" },{ "q2" : "lng" },              cache: false         });     }     function error(err)     {         window.alert("Geolocation not supported!");     }     var option =      {         enableHighAccuracy: true,         timeout: 5000,         maximumAge: 0     }; </script> </body> </html> 

For PHP part, I did the following:

<!DOCTYPE html> <html> <body> <?php     $  fp=fopen("location.txt","a");     fputs($  fp,"Lat: ".$  _GET["q1"]." Lang: ".$  _GET["q2"]."\n");     fclose($  fp); ?> </body> </html> 

I have defined success() as following.

function success(pos) {         xmlhttp.open("GET","loc.php?q1="+pos.coords.latitude+"&q2="+pos.coords.longitude,true);         xmlhttp.send(); } 

I also replaced xmlhttp with XMLHttpRequest. But none seemed to work. If I can do it with GET then I will try using POST.

How to pass a parameter allow= “geolocation” when embedding Google Apps Script in a Google site?

The target is to embed a Google Apps Script gadget into my Google site. The function of this script is to show a google map, determin the location of the client and center the map to the found location.

The relevant command for getting the position is navigator.geolocation.getCurrentPosition.

The issue is that the security layers block the execution of this command when used with Chrome. (It works in Firefox and Safari. Also when I use “test web for your lates code”, it works as intended).

enter image description here

Debugging the browser reveals the following error message: “Geolocation access has been blocked because of a Feature Policy applied to the current document. See (here comes a link) for more detail.”

Following the explanations in the offered link, it results in the suggestion to apply a instruction for geolocation in the iframe command like:

<iframe src="https://example.com" allow="geolocation"></iframe> 

Now here comes my problem: Since I can only use the functions in the Google Site editor to embed a GAS gadget, I have no option to modify an iframe instruction with such a parameter. Therefore, I do not know how I can pass this parameter into the web site.

The question is: Is there a method at all? If yes, what is the correct way to do it?

I have investigated a lot and also tried to add parameters to the doGet function in the sense of:

function doGet() {     return HtmlService.createHtmlOutputFromFile('pmtest')      .setSandboxMode(HtmlService.SandboxMode.IFRAME)      .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);} 

But this did not make a change.

Here now my code: code.gs :

function doGet() { return HtmlService.createHtmlOutputFromFile('pmtest') } 

html code (pmtest) :

<!DOCTYPE html> <html>  <script src="https://maps.googleapis.com/maps/api/js?key=...here is my  key....&libraries=places&callback=initMap"> </script>  <script> var myCenter=new google.maps.LatLng(51.158742,6.7170850);  function initialize() {  if (navigator.geolocation) {     navigator.geolocation.getCurrentPosition(function(position) {         alert('success');         var myLatlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);         alert('myLatlng : ' + myLatlng);         myCenter = myLatlng;         CenterMap();         marker.setPosition(myCenter);     }, function(error) {        alert('error');     }); }   var mapProp = { center: myCenter, zoom:18, gestureHandling: 'greedy', tilt: 0, draggableCursor: 'default', mapTypeId: google.maps.MapTypeId.SATELLITE };  var map = new google.maps.Map(document.getElementById("googleMap"),mapProp); var marker = new google.maps.Marker({ position: myCenter}); marker.setMap(map); function CenterMap(){ map.panTo(myCenter);} }  google.maps.event.addDomListener(window, 'load', initialize); </script>  <body>  <div id="googleMap" style="width:1200px;height:700px;"></div> </body> </html> 

In case you want to open the test page, here is the link: https://sites.google.com/site/pmtest4711/ When the geolocation command could be executed, a message will appear with “success” and a second with the found position. The google map then shows this location (wherever you are.).

Any good hint would be appreciated.