PHP: how to use GPS Long,Lat coordinates in Map

I am making a “friend finder” web-based mobile app for school. Now i retrieve the Latitude and longtitude coordinates via GPS , when i retrieve those i want my script to center the map at these coordinates and place a marker there But it won’t work and i’m out of ideas , so can anyone help me ?.

My code : [php]

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Find Friends Web App</title>
<meta name="viewport" content="width=device-width, initial-scale=1"> 
	<link rel="stylesheet" href="" />
<script src=""></script>
<script src=""></script>
<script type="text/javascript" src=""></script>	
<script src="scripts/"></script>
				function useposition(position){  
			lat = position.coords.latitude;
			lon = position.coords.longitude;   
			$("location")(  lat + ', ' + lon);

As you can see i fetch the lat,long coordinates and try to store them in location. Then i try to center my map at the lat,long coordinates stored in location. But it won’t work :frowning:

Some of your code I just don’t understand.

I don’t know what this is supposed to do: $(“location”)( lat + ', ’ + lon)

This element doesn’t appear to exist in your HTML: document.getElementById(“map”)

I would recommend reading this tutorial:

Sponsor our Newsletter | Privacy Policy | Terms of Service