Jump to content

Finding location from Latitude and longitude


gozoober

Recommended Posts

Hi,

 

I am sure this has been asked before but I could not find it.  Basically I have a database with property listings along with latitudes and longitudes for each property.

 

Is there a php script that can tell me the location when it's passed the latitude and longitude so I know the location that each property is in?

 

Thanks,

 

Richard

As far as writing it... I have no idea.. but I needed a store locator for the new website I am creating for my job and found a great google mapping tool at code322.com. It is not super cheap, but it is very good. You can pass an address string or lat/lon

 

Thats the best I can do for ya.

 

Yes, it makes sense, read what I said.

 

Use a WHERE clause in your query with the latitude and longitude values.

 

DarkWater, I am not sure what you mean by this. Just adding a where clause is not going to accomplish what the poster wants. Could you explain more for both my benefit and the original posters benefit?

 

Nate

try this code out. change the $daddr to pull the data from your db

<?php $daddr= "some_GPS_code"; ?>
<form name="form1">
Enter your address:
	<!-- input field where the user can enter the source address-->
	<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" />
	<br>
	<!-- html button with a javascript function attached to it to show the directions in the iframe-->
	<INPUT value="Get Directions" TYPE="SUBMIT" onclick="javascript:GetDirections();return false;">
	<BR>
	<BR>		
	<!-- the iframe to show the directions, this is invisible when the page first loads, since the source attribute is empty  -->

	<iframe id="mapframe" name="mapframe" src=""  frameborder="0" width="640px" height="480px">
	</iframe>			
</form>

<script language="javascript">			
	function GetDirections()
	{				
		var SourceAdress = 'saddr=';

		var DestinationAddress = 'daddr=<?php print $daddr; ?>'; //hardcoded value for the destination address
		var Url = '';
		//read out source adress from the input field
		SourceAdress += document.form1.saddr.value;	
		//form the url 
		Url = 'http://maps.google.com/maps?' + SourceAdress + '&' + DestinationAddress; // + '&output=html';	

		//open url in iframe
		frames['mapframe'].location.href = Url;			

		//you can use the line below to show the directions in a popup window, don;t forget to comment out the line above... 
		//window.open(Url,'directions','width=1024,height=768,scrollbars=yes,toolbar=no,location=no, resizable=no'); 			
	}

</script>

Hope this helps

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.