Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
First iam sorry because my English is not good
I want to put Google map when a new member determines automatic lcation and keeps it in my database
Posted
Updated 7-Nov-15 12:28pm
v2

store only longitude and latitude and you can get actual map
 
Share this answer
 
Use HTML5 Geolocation[^] for getting the user's location -
JavaScript
<script>
var lat = 0; lon = 0;
var x = document.getElementById("demo");
function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    } else {
        x.innerHTML = "Geolocation is not supported by this browser.";
    }
}
function showPosition(position) {
    lat = position.coords.latitude;
    lon = position.coords.longitude; 
}
</script>


And those lat and lon in google's map -
JavaScript
function initialize() {
  var mapProp = {
    center:new google.maps.LatLng(lat, lon),
    zoom:5,
    mapTypeId:google.maps.MapTypeId.ROADMAP
  };
  var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
}
google.maps.event.addDomListener(window, 'load', initialize);


Refer this - Create a Basic Google Map[^]

-KR
 
Share this answer
 
v2

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