PDA

View Full Version : Need help with google map integration



Laimonas171
02-20-2011, 07:01 PM
Got it work. Thank you for help guys.

Hi,

so i need to create an web application with two vars,

[a:var] and [b:var]

so with these two variables i need to get small map 300x400 or sth like that, so main problem is all tutorial that i found uses x and y values on map.

main point what i need is use these to variables as strings (location names).

Example. A=Lithuania, B=Paris.


so if i put these variables i want to see map with road from A to B spots.
Any ideas how to integrate that or anyone know where to find tutorial how to do that?

Thank you for answers. bold part, i need to change to my vars..

EDIT:
---------------------------------------------------
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0px; padding: 0px }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=set_to_true_or_false">
</script>
<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
}

</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>

------------------------------------

this one works fine, but it works on cords, bold part.

EDIT: Working version.
-----------------------

<?php
echo "<form method=get>IŠ:<input type='text' name=a> I:<input type='text' name=b><input type='submit' value=Rodyti></form>";
error_reporting(5);//Neberodo klaidu
//tikrina ar igauti kelio kintamieji
if($_GET['a']<>'' and $_GET['b']<>''){
$a = $_GET['a'];
$b = $_GET['b'];
echo "<iframe width=\"765\" height=\"350\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\"
src=\"http://maps.google.lt/maps?f=d&amp;source=embed&amp;saddr=".$a."&amp;daddr=".$b."&amp;hl=lt&amp;t=h&amp;output=embed\" style=\"color:#0000FF;text-align:left\"></iframe><br />";
}
?>

Harry
02-20-2011, 07:20 PM
Did you try reading http://code.google.com/apis/maps/index.html ? They give some examples there, might be what you're looking for.

Laimonas171
02-20-2011, 08:29 PM
Did you try reading http://code.google.com/apis/maps/index.html ? They give some examples there, might be what you're looking for.

yeap, but everywhere wrote about cords, i found solution




$a = "Kaunas"; // city in Lithuania
$b = "London";
echo "<iframe width=\"625\" height=\"350\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\"
src=\"http://maps.google.lt/maps?f=d&amp;source=s_d&amp;saddr=".$a."&amp;daddr=".$b."&amp;geocode=Fax0VQMdK79jASmJfM5JXOLlRjEA2-lwjNEABA%3BFVt-6QIdi98jACkPt-IGH27mRzFglIxow4ILBA&amp;hl=lt&amp;sll=55.903965,23.356225 &amp;sspn=0.000982,0.002586&amp;ie=UTF8&amp;ll=52.380085,12.83 233&amp;spn=7.10435,20.96314&amp;t=h&amp;output=embed\"></iframe><br />";

so now problem is with geocode var is generated automatically embed from original google maps page. so if i change variables it change a and b spots, but do not show curve from a to b... and i don't know how to generate it..

Laimonas171
02-24-2011, 08:41 PM
<?php
echo "<form method=get>from:<input type='text' name=a> to:<input type='text' name=b><input type='submit' value=show></form>";
error_reporting(5);//do not shows var errors.
//check or both of vars are wroten
if($_GET['a']<>'' and $_GET['b']<>''){
$a = $_GET['a'];
$b = $_GET['b'];
echo "<iframe width=\"765\" height=\"350\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\"
src=\"http://maps.google.lt/maps?f=d&amp;source=embed&amp;saddr=".$a."&amp;daddr=".$b."&amp;hl=lt&amp;t=h&amp;output=embed\" style=\"color:#0000FF;text-align:left\"></iframe><br />";
}
?>