Bekijk de onderstaande video om te zien hoe je onze site als een web app op je startscherm installeert.
Opmerking: Deze functie is mogelijk niet beschikbaar in sommige browsers.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://maps.googleapis.com/maps/api/directions/json?origin='. $center_lat .','. $center_lng .'&destination='. $row['lat'] .','. $row['lng'] .'&sensor=false');
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$data = curl_exec($ch);
curl_close($ch);
$json = json_decode($data);
$newnode->setAttribute("distance", $json->routes[0]->legs[0]->duration->text);
while ($row = @mysql_fetch_assoc($result)){
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("id", $row['id']);
$newnode->setAttribute("name", $row['name']);
$newnode->setAttribute("address", $row['address']);
$newnode->setAttribute("postcode", $row['postcode']);
$newnode->setAttribute("lat", $row['lat']);
$newnode->setAttribute("lng", $row['lng']);
$newnode->setAttribute("distance", $row['distance']);
$newnode->setAttribute("telefoon", $row['telefoon']);
$newnode->setAttribute("fax", $row['fax']);
$newnode->setAttribute("website", $row['website']);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://maps.googleapis.com/maps/api/directions/json?origin='. $center_lat .','. $center_lng .'&destination='. $row['lat'] .','. $row['lng'] .'&sensor=false');
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$data = curl_exec($ch);
curl_close($ch);
$json = json_decode($data);
$newnode->setAttribute("distance", $json->routes[0]->legs[0]->duration->text);
}
<?php
require("phpsqlsearch_dbinfo.php");
// Get parameters from URL
$addressInput = $_GET["addressInput"];
$address = $_GET["address"];
$id = $_GET["id"];
?>
<!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" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<title>Google Maps JavaScript API Example: Simple Directions</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<script src="http://maps.google.com/maps?file=api&v=2.x&key=ABQIAAAA_Sg9KB9fS0B6Jtnx32Gv3hSip7-AWJrOd2SAL32NdKadpXt5whTdXmj-ovyivwV61uLA-I_K3lji0A"
type="text/javascript"></script>
<script type="text/javascript">
// Create a directions object and register a map and DIV to hold the
// resulting computed directions
var map;
var directionsPanel;
var directions;
function initialize() {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(52.372246, 4.894409), 6);
directionsPanel = document.getElementById("route");
directions = new GDirections(map, directionsPanel);
directions.load("from: <? echo "addressInput"; ?> to: <? echo "address"; ?>");
}
</script>
</head>
<body onload="initialize()">
<div id="route" style="width: 25%; height:480px; float:right; border; 1px solid black;"></div>
<br/>
</body>
</html>
<a href="#" onclick="calcRoute()">Bereken route</a>
Je bouwt immers markers op basis van de XML-data.
In de openInfoWindowHtml() zorg je dat dit er bij komt:
Waarschijnlijk moet je wel de functie wat parameters mee geven zodat het een start en eindpunt heeft.HTML:<a href="#" onclick="calcRoute()">Bereken route</a>
function calcRoute() {
var start = document.getElementById('addressInput').value;
var end = document.getElementById("address").value;
var request = { origin:start, destination:end, travelMode: google.maps.DirectionsTravelMode.DRIVING };
directionsService.route(request, function(result, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(result); } }); }
function createMarker(point, name, address, telefoon, fax, website, email) {
var marker = new GMarker(point);
var html = '<b>' + name + '</b> <br/>' + address + '</b> <br/><br/>T: ' + telefoon + '</b> <br/>F: ' + fax + '</b> <br/><br/><a href="' + website + '" target="_blank">' + website + '</a><br/><a href="mailto:' + email + '">' + email + '</a><br/><br/><a href="#" onclick="calcRoute()"> routebeschrijving</a></b>';
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
Waarschijnlijk moet je wel de functie wat parameters mee geven zodat het een start en eindpunt heeft.
We gebruiken essentiële cookies om deze site te laten werken, en optionele cookies om de ervaring te verbeteren.