Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello I am using this google map to select user location when user wont to register select latitude and longitude and display in map.

code select my location from latitude and longitude but not display in map.

this is the link for test http://prestito.engmutaz-ghosheh.com/html/register.php/

and this is the code i am using:

JavaScript
<script>
	var options = {
  enableHighAccuracy: true,
  timeout: 5000,
  maximumAge: 0
};

function success(pos) {
  var crd = pos.coords;
alert("Location changed. New location (" + crd.latitude + ", " + crd.longitude + ")");
  console.log('Your current position is:');
  console.log('Latitude : ' + crd.latitude);
  console.log('Longitude: ' + crd.longitude);
  console.log('More or less ' + crd.accuracy + ' meters.');
};

function error(err) {
	alert("Err");

  console.warn('ERROR(' + err.code + '): ' + err.message);
};

	navigator.geolocation.getCurrentPosition(success, error, options);

	function initialize() {
  var mapProp = {
    center:new google.maps.LatLng(31.9497,35.9328),
    zoom:5,
    mapTypeId:google.maps.MapTypeId.ROADMAP
  };
  var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
}
google.maps.event.addDomListener(window, 'load', initialize);
Posted
Updated 5-Dec-15 21:15pm
v2

1 solution

You need to set the new position in the call to
JavaScript
center:new google.maps.LatLng(31.9497,35.9328)
; i.e. use the variables crd.latitude and crd.longitude that you captured previously.
 
Share this answer
 

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