Quantcast
Channel: Adobe Community : Unanswered Discussions - ColdFusion
Viewing all articles
Browse latest Browse all 5794

Find user location (Please help me fix below or suggest any other way)

$
0
0

Hi

 

Hopefully, some one can help me with this issue. I am trying to implement a global site and hence was looking for a way to detect user location. I do not want to use any ip2location webservice or download a database or ask for user to "share location".

 

Anyways, I found this project. I implemented it , it detects my location correctly (US). However for my friend in Germany it is returning an empty string for Country.

 

http://javainetlocator.sourceforge.net/. I am using jar file from here. http://sourceforge.net/projects/javainetlocator/files/ with version 2.23

 

I am using CF 11 and my code is on

 

http://roomdu.com/geolocator/

 

PLEASE SUGGEST ME

 

  <cfset ipAddress=cgi.REMOTE_ADDR>

       <cfset geoLocator=createobject("component","remoteClassPath_geoLocator")>

       <cfset Ok=geoLocator.init()>

    

              <cfset thisLocale=geoLocator.findLocale(ipAddress,cgi.HTTP_ACCEPT_LANGUAGE)>

              <cfset thisCountry=geoLocator.findCountry(ipAddress,cgi.HTTP_ACCEPT_LANGUAGE)>

              <cfset thisLanguage=geoLocator.findLanguage(ipAddress,cgi.HTTP_ACCEPT_LANGUAGE)>

              <cfset thisC=geoLocator.showCountry(ipAddress)>

              <cfset thisL=geoLocator.showLanguage(ipAddress)>

              <cfset bLocaleValid=geoLocator.isValidLocale("fr_RU")>

<cfif ok>

       <cfoutput>

       <b><h2>Not your grandmother's geoLocator Remote</h2></b>

       <hralign="left"width="30%">

       <b>geoLocator</b> := Initialized plenty fine.

       <br>

       <b>ip address</b> := #ipAddress#

       <br>

       <b>browser http_accept_language</b> := #cgi.HTTP_ACCEPT_LANGUAGE#

       <br>

       <b>This locale from geoLocator</b> := #thisLocale#

       <br>

       <b>This country (2 letter code) from geoLocator</b> := #thisCountry#

       <br>

       <b>This language (2 letter code) from geoLocator</b> := #thisLanguage#

       <br>

       <b>This country from geoLocator</b> := #thisC#

       <br>

       <b>This language from geoLocator</b> := #thisL#

       <br>

       <b>Test fr_RU as valid locale</b> := #yesnoFormat(bLocaleValid)#

       </cfoutput>

       <br>

       <tablecellspacing="1"cellpadding="1"width="300"height="210">

       <tr>

       <tdvalign="top"title="Flash World Map">

       <OBJECTclassid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"

        codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"

        WIDTH="300"HEIGHT="200"id="world"ALIGN="">

        <PARAMNAME=movieVALUE="world.swf">

        <PARAMNAME=qualityVALUE=high>

        <cfoutput><PARAMNAME='Flashvars'VALUE='country=#thisCountry#&colover=FFCC00&colsel=FF0000'></cfoutput>

        <PARAMNAME=bgcolorVALUE=#66CCFF>

        <EMBED src="world.swf" quality=high bgcolor=#66CCFF WIDTH="300" HEIGHT="200" NAME="world" ALIGN=""

        TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>

       </OBJECT>

       </td>

       </tr>

       <tr>

       <tdstyle="{font-size : 9px;}">flash map provided by <ahref="mailto:eric.mauviere@emc3.fr"style="{font-size : 9px;}">eric mauviere</a></td>

       </tr>

       </table>

<cfelse>

       Oops, poop hit the fan.

</cfif>


Viewing all articles
Browse latest Browse all 5794

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>