View Full Version : Getting Longitude and Latitude
letom
05-16-2013, 04:55 AM
Normally we get/browser/ operating system some more details of our site user, from back end of website by calling a simple coding in php.
My Qs is, Is there any way to get the longitude and latitude of a visitor of our site in php ?
Mod's note:
this type of generic, open-ended question does not usually generate good discussions, either because the question is too broad, there is no clear answer, or the answers are too subjective.
It would probably be more productive for you to do some research (Google is your friend! (http://lmgtfy.com/?q=getting+Longitude+and+Latitude+of+IP+address%2Fclient+in+PHP)), and then come back here if you find a specific question to ask.
Because this type of discussion is often unproductive and may attract spam, this thread may be closed or deleted later.
letom
05-16-2013, 06:56 AM
TKS ....
Yes This is wide, but experts can give a solution to certain extent.
If it not feasible to answer the question.. terminate the thread now, i will consult to other forums which gives valuable information about this common topic.
keyboard
05-16-2013, 07:32 AM
My Qs is, Is there any way to get the longitude and latitude of a visitor of our site in php ?
There is no built in easy way, but there are services that provide that functionality. Read (http://php.net/manual/en/function.geoip-record-by-name.php)
(uses GeoIP - http://php.net/manual/en/book.geoip.php)
HOWEVER, you won't be getting the user's latitude and longitude, it'll be their ISP (Internet Service Provider).
Probably can tell you the area they're in, but not their exact location.
As well as this, the data isn't 100% accurate.
djr33
05-16-2013, 08:22 AM
In PHP alone, no. But with a database that lists geographic locations for IPs, yes. You'll need something third party.
GeoIP (as in keyboard's post) is a reasonable option (although there are a few others). I don't think it comes automatically installed in PHP, so you have to add it. Or you can add it manually, along with the PHP functions they supply. It comes either as a database or an organized (and efficient) flat file.
Note that the free version is a little less accurate than the paid version, but both work well.
However, I agree with traq here: you can find a lot of information by using Google. There are some new technologies such as for mobile devices that will give you more accurate information, in different ways.
And not only Google, but also please search for old threads here. We've discussed this (and GeoIP) a number of times on the forum. If it has already been asked and answered, please read that first. Effective searching can save you (and us) a lot of time.
letom
05-16-2013, 09:46 AM
There is no built in easy way, but there are services that provide that functionality. Read (http://php.net/manual/en/function.geoip-record-by-name.php)
(uses GeoIP - http://php.net/manual/en/book.geoip.php)
HOWEVER, you won't be getting the user's latitude and longitude, it'll be their ISP (Internet Service Provider).
Probably can tell you the area they're in, but not their exact location.
As well as this, the data isn't 100% accurate.
Thanks for your information, Yes I know the information you provided, and know it is not 100% accurate, [I]Previously i had practically tested it to a certain extent..but totally meaning less ... then this ip is sufficient to trace the user details, or any other we want to collect for our future reference if any, other than ip..
... then this ip is sufficient to trace the user details, or any other we want to collect for our future reference
It will depend on what details you want to track, but generally, no - since many people have dynamic IP addresses, there's no way to be sure their IP (or their ISP's IP) will be the same from one request to the next.
Things that would be useful to know about your question:
...what "details" do you want to track?
...why do you want to know the user's lat/long?
djr33
05-16-2013, 09:14 PM
There are lots of things you can approximate. There's basically nothing that you can know with 100% certainty.
letom
05-17-2013, 04:51 AM
It will depend on what details you want to track, but generally, no - since many people have dynamic IP addresses, there's no way to be sure their IP (or their ISP's IP) will be the same from one request to the next.
Things that would be useful to know about your question:
...what "details" do you want to track?
...why do you want to know the user's lat/long?
Thanks...
...what "details" do you want to track?
Asking a Question "what "details" do you want to track?" for my Question "ip is sufficient to trace the user details ?, or any other we want to collect for our future reference if any, other than ip.."" .. is meaning less, i have nothing to do with that.
why do you want to know the user's lat/long?
When some unknown person is getting into my home as a visitor, i will ask the details, where he come from/what purpose/where he is staying ? not only me but all people will ask...FYI, Your Question is not the main subject of this thread, / but if you ask that type of Questions i need to talk beyond the subject
Asking a Question "what "details" do you want to track?" for my Question "ip is sufficient to trace the user details ?, or any other we want to collect for our future reference if any, other than ip.."" .. is meaning less, i have nothing to do with that.
In some cases, the user's IP address will be sufficient to achieve your goals; in others, it will not. I asked you about this to help give a useful answer to your question.
...which are the details normally we require to track a visitor ?
...was the only actual "question" from your original post. What "details" you decide to track is determined directly by what you intend to do with them: are you trying to get usage statistics? serve different content based on region/language? improve security? build a marketing profile? All of these things would require tracking different information about your users (and different legal precautions, as well).
When some unknown person is getting into my home as a visitor, i will ask the details, where he come from/what purpose/where he is staying ? not only me but all people will ask...
Your website is a bit different than your house.
To be clear, however, I am not asking you to justify your decision; nor am I suggesting that there is any need to. I am asking what you are trying to accomplish, again, so I might answer the question you asked.
FYI, Your Question is not the main subject of this thread, / but if you ask that type of Questions i need to talk beyond the subject
No, my questions are not the subject of your thread. Your question is. That is the question that I am trying to discover more about; to try and understand your . Discussing such things is not "beyond the subject."
If you do not wish to provide any further details, that is, of course, up to you. However, I cannot "guess" what solution would work best for an unknown problem.
"GeoIP" is something of a broad answer to a broad question, and if it's enough to get you started, that's great. If not, you'll need to let us in on the problem a bit more.
letom
05-18-2013, 05:17 AM
Dear Mr Adrain
If any additional information i require, i will consult beyond the forum
Thanks..
Tom
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.