Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Geo fencing & Different content

Options
  • 24-10-2012 9:15pm
    #1
    Registered Users Posts: 6,046 ✭✭✭


    Just wondering if there was a way that a particular word or phrase or even whole sentences/paragraphs etc could be changed in (for example) HTML 5, through geofencing ?

    EG, if someone is looking at something online while in ROI, I could feed different content to someone looking at the same page while in UK or NI. Say substituting a person's name -

    ROI: Sean got in the car & drove to Dublin airport
    UK: Peter got in the black cab & drove to Canary Wharf
    NI: Sandra got in the car & drove to Great Victoria Street railway station

    Basically the content would be localised to the geographic area. Would that be possible ?


Comments

  • Closed Accounts Posts: 6,281 ✭✭✭Ricky91t


    Ok I'm a bit confused, but do you mean you want to get the users location and change a string/sentence based on their location?

    If so there's two ways to do it, first using their IP, you can possibly do this in javascript, locate them using this and figure out a way to find a POI in that country and put it in the sentence.

    The other, is using the geolocation service built into the HTML5, the issue with this is that the user will be prompted to enable geolocation meaning the string will be empty/default until they've done this and your look up is done.


  • Registered Users Posts: 6,046 ✭✭✭OU812


    Thanks for that Ricky. Using the second method, could you have a default sentence stored locally to substitute if geolocation was not enabled ?

    Non Geo Located: He got in the car & drove to the airport

    Geo Located: ROI: Sean got in the car & drove to Dublin airport
    UK: Peter got in the black cab & drove to Canary Wharf
    NI: Sandra got in the car & drove to Great Victoria Street railway station


  • Closed Accounts Posts: 6,281 ✭✭✭Ricky91t


    Yep! You'd could have that within a p tag, with an ID.

    [HTML]<p id='localisedSentence'>He got in the car & drove to the airport</p>
    [/HTML]


    And then the script would be:
    <script>
    var sentence=document.getElementById("localisedSentence");
    function getLocation()
      {
      if (navigator.geolocation)
        {
        navigator.geolocation.getCurrentPosition(showPosition);
        }
      //failed so leave default string
      //else{x.innerHTML="Geolocation is not supported by this browser.";}
      }
    function showPosition(position)
      {
      //initialise vars with defaults incase resolving user location fails
      var localised_transport = 'car';
      var localised_POI = 'airport';
      var localised_Name = 'He';
      //Somehow resolve the lat and long to a country
      //generate localised values and store in above vars
    
      sentence.innerHTML= localised_Name + " got in the " + localised_transport + " and drove to " + localised_POI; 
      }
    </script>
    

    Yes, there's some gray spots there, I'm not aware(though I've never looked) of a service that will give you information like that, If it's only a few countries you could hard code minimum and maximum coordinates of each country and check to see if the user is within those and update variables accordingly.

    I got the code from here. http://www.w3schools.com/html/html5_geolocation.asp


  • Registered Users Posts: 6,046 ✭✭✭OU812


    Thanks so much !


Advertisement