[Google Maps API v2] PHP Variables in origin and destination
Hello
I'm stuck with one problem. I wanna set my origin and destination from php variables so i can connect it later with my mysql but this just don't wanna work. Can anybody help me with this?
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css" media="all">@import "/style/Przyklad.css";</style>
<title>Przykład</title>
<script src="http://maps.google.com/maps/api/js?sensor=false&language=pl" type="text/javascript"></script>
<style type="text/css">
#wskazowki
{
font-family: Tahoma;
font-size: 11px;
height: 350px;
width: 300px;
overflow: auto;
}
</style>
</head>
<body onload="mapaStart()">
<script type="text/javascript">
<!--
var my_var = "<?php $kek='Lublin'; echo json_encode($kek); ?>";
var mapa; // obiekt globalny
var dymek = new google.maps.InfoWindow();
// niezbędne elementy do wyznaczenia trasy:
var trasa = new google.maps.DirectionsService();
var trasa_render = new google.maps.DirectionsRenderer();
function mapaStart()
{
var wspolrzedne = new google.maps.LatLng(53.41935400090768,14.58160400390625);
var opcjeMapy = {
zoom: 10,
center: wspolrzedne,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
mapa = new google.maps.Map(document.getElementById("mapka"), opcjeMapy);
// ustawienie docelowej mapy i kontenera na wskazówki
trasa_render.setMap(mapa);
trasa_render.setPanel(document.getElementById('wskazowki'));
}
function znajdz_wskazowki(my_var)
{
var dane_trasy =
{
origin: my_var,
destination: 'Gdańsk',
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
trasa.route(dane_trasy, obsluga_wskazowek);
}
function obsluga_wskazowek(wynik, status)
{
if(status != google.maps.DirectionsStatus.OK || !wynik.routes[0])
{
alert('Wystąpił błąd!');
return;
}
trasa_render.setDirections(wynik);
}
-->
</script>
<table style="border: 0 collapse;">
<tr>
<td style="width: 410px;">
<div id='mapka' style='width: 400px; height: 350px; border: 1px solid black; background: gray;'></div>
</td>
<td style="width: 300px; border: 1px solid black;" valign="top">
<div id="wskazowki">
</div>
</td>
</tr>
</table>
<input type="button" value="Trasa przewozu" onclick="znajdz_wskazowki(my_var)" />
<p id="info">
Kliknij na powyższy przycisk aby wyznaczyć trasę dojazdu wraz ze wskazówkami (listą kroków)
</p>
</body>
</html>
--
You received this message because you are subscribed to the Google Groups "Google Maps API V2" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-api/-/tCRpVYKj_i0J.
To post to this group, send email to google-maps-api@googlegroups.com.
To unsubscribe from this group, send email to google-maps-api+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-api?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home