Click here to Skip to main content
15,166,099 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need a web visitors latitude and longitude to mark the point on google map
? I have achieved this google map api.but its asking visitors permission,how to avoid asking permission? or is any other way to achieve this?
Posted
Comments
Richard MacCutchan 16-Dec-14 12:44pm
   
Why do you want to hide this from the user? Perhaps you are trying to do something illegal.
chandubbbb 16-Dec-14 13:05pm
   
i dont want to do any illegal thing .i want to show background layer of login page
as their location. most of the people dont see or dont allow it thats why iam asking?
if u know the answer give me solution? other wise dont throw ur intetion over here
Richard MacCutchan 16-Dec-14 13:16pm
   
Not everyone wants that information to be made available, and for good reasons.
alfcas 16-Dec-14 13:20pm
   
Richard MacCutchan is allowed to write his opinion here. If you don't like it, well, it is your problem. In addition, you cannot say to everyone what to do or not to do. I suppose that even my opinion doesn't solve your problem, but it can be very usefull for you.
chandubbbb 17-Dec-14 5:21am
   
first read Richard's comment?
what he has said "Perhaps you are trying to do something illegal."
alfcas 18-Dec-14 13:59pm
   
come on, try to give to the term "illegal" the meaning that a programmer usually gives ("illegal characters in path", for example), you are not talking to lawyers :-)
chandubbbb 19-Dec-14 0:00am
   
i landed in this site for some suggestion or help not for arguing with you guys.if u people want to help do so other wise dont discourage people those who want to take help or who want to give solutions
Philippe Mori 16-Dec-14 16:46pm
   
What would be the purpose of having browser ask permission if it can be disabled? The purpose of the prompt is exactly to avoid site like yours getting user coordinates without its knowledge.

It's a browser issue and not something you can control via code for security reasons.
   
The closest you'd get to their location without explicitly asking for their location data is by their IP address - which will only be accurate if they are on a home WiFi - 3G/4G IP addresses will not give you any accurate location data.

Check out Codehelper API[^] - that is a JS based library and in-fact I answered someones location by javascript question here: find user location based on ip address is not working[^]

Here's what it involves:
HTML
<script src="http://www.codehelper.io/api/ips/?js"></script>
<script>
window.onload = function(){
    console.log(codehelper_ip);
};
</script>


Which returns a JSON object:
JavaScript
{"IP":"149.215.142.9","ContinentCode":"EU","ContinentName":"Europe","CountryCode2":"GB","CountryCode3":"GBR","Country":"GB","CountryName":"United Kingdom","RegionName":"Unknown","CityName":"Unknown","CityLatitude":51.5,"CityLongitude":-0.13,"CountryLatitude":54,"CountryLongitude":-4.5,"LocalTimeZone":"Europe/London","REMOTE_ADDR":"149.215.142.9","HTTP_X_FORWARDED_FOR":"149.215.142.9","CallingCode":"44","Population":"61,113,205 (22)","AreaSqKm":"243,610 (80)","GDP_USD":"2.226 Trillion (7)","Capital":"London","Electrical":"230 V,50 Hz Type G","Languages":"English, Welsh (about 26% of the population of Wales), Scottish form of Gaelic (about 60,000 in Scotland)","Currency":"Pound Sterling (GBP)","Flag":"http://www.codehelper.io/api/ips/proips/flags/GB.jpg"}


My suggestion is that you could use this and still request their lat/long - if they provide it then great you get a more accurate location - if not, you get a general idea of where they are.
   
Comments
chandubbbb 17-Dec-14 5:26am
   
thank u for your solution its worked for me
Chubby Ninja 17-Dec-14 6:14am
   
Glad it helped :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900