Store locator script
Graag wil ik een store locator script, maar de scripts die ik kan vinden zijn véél te uitgebreid. Het enige dat ik zou willen is dat de lat en long worden opgeslagen in mijn database, en dat ik via een klein zoek form kan kijken welke store binnen een afstand van 20 km in de buurt ligt...
Ik probeer dit zelf al erg lang te maken en te zoeken, maar mij lukt het echt niet. Is er eventueel iemand die of de gouden tip heeft, of dit voor mij kan ontwikkelen voor een leuk prijsje (€50,-)??
Groetjes,
Anne
Laat anders zien wat je hebt, dan kunnen we je waarschijnlijk beter helpen. Als je dit wilt laten maken moet je topic in aanvragen staan.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!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></title>
<meta http-equiv="content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="verify-v1" content="K8eGACCrm4Azib1o2Tk+4UQ9UJX1jk5WtQzsx4f8hVQ=" />
<meta name="y_key" content="b0c2a0e275c4c2b0" />
<meta name="revisit-after" content="7 Days" />
<meta name="ratings" content="general" />
<meta name="robots" content="all">
<meta name="language" content="nl">
<meta http-equiv="Window-target" content="_top">
<script src="http://maps.google.nl/maps?file=api&v=2&key=ABQIAAAA_wv_4fNQXqbDmK8uXDPT4RS9Sno1k1HZ50fKzSL6k_Xo9VwKFRTEUFPMJm54Q8Sd8uANkz1nfIONvA" type="text/javascript"></script>
</head>
<body onload="initialize()" onunload="GUnload()">
<form action="#" onsubmit="setDirections(this.from.value, this.to.value, 'nl'); return false">
<table border="0">
<tr>
<td>Postcode: </td><td><input type="text" size="10" id="zoek_postcode" name="from"></td>
<td><input tabindex="1" name="submit" type="submit" value="Zoek"></td>
</tr>
</table>
<?php
require_once 'db_config.php';
$sql = "
SELECT
naam,
postcode
FROM
bedrijf
ORDER BY
naam ASC
";
if(!$res = mysql_query($sql))
{
trigger_error(mysql_error().'<br>In query: '.$sql);
}
elseif(mysql_num_rows($res) == 0)
{
echo 'Geen resultaten gevonden';
}
else
{
while($row = mysql_fetch_assoc($res))
{
echo 'Afstand naar '.$row['naam'].':<input type="hidden" id="test" name="to" value="'.$row['postcode'].'"></form><div id="afstand" style="font-weight: bold;"></div>';?>
<form action="#" onsubmit="setDirections(this.from.value, this.to.value, 'nl'); return false">
<table border="0">
<tr>
<td>Postcode: </td><td><input type="text" size="10" id="zoek_postcode" name="from"></td>
<td><input tabindex="1" name="submit" type="submit" value="Zoek"></td>
</tr>
</table>
<script type="text/javascript">
function initialize()
{
if (GBrowserIsCompatible())
{
// nieuw object ZONDER parameters, want we willen nl. geen geschreven route EN geen map tonen....
// http://code.google.com/apis/maps/documentation/reference.html#GDirections
gdir = new GDirections();
GEvent.addListener(gdir,"load", set_distance);
}
}
function setDirections(zoek_postcode, test, locale)
{
// http://code.google.com/apis/maps/documentation/reference.html#GDirectionsOptions
gdir.load("from: " + zoek_postcode + " to: " + test, {locale: locale, travelMode:G_TRAVEL_MODE_DRIVING,avoidHighways: false} );
}
function set_distance()
{
// extra: foutafhandeling, kan handig zijn!!!
handleErrors();
document.getElementById("afstand").innerHTML = gdir.getDistance().html;
}
function handleErrors()
{
// http://code.google.com/apis/maps/documentation/reference.html#GGeoStatusCode
if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_MISSING_QUERY || gdir.getStatus().code == G_GEO_MISSING_ADDRESS)
alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_BAD_KEY)
alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_UNAVAILABLE_ADDRESS)
alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_UNKNOWN_DIRECTIONS)
alert("The GDirections object could not compute directions between the points mentioned in the query. This is usually because there is no route available between the two points, or because we do not have data for routing in that region.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_TOO_MANY_QUERIES)
alert("The given key has gone over the requests limit in the 24 hour period or has submitted too many requests in too short a period of time.\n Error code: " + gdir.getStatus().code);
}
</script>
<?php
}
}
?>
</body>
</html>
"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></title>
<meta http-equiv="content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="verify-v1" content="K8eGACCrm4Azib1o2Tk+4UQ9UJX1jk5WtQzsx4f8hVQ=" />
<meta name="y_key" content="b0c2a0e275c4c2b0" />
<meta name="revisit-after" content="7 Days" />
<meta name="ratings" content="general" />
<meta name="robots" content="all">
<meta name="language" content="nl">
<meta http-equiv="Window-target" content="_top">
<script src="http://maps.google.nl/maps?file=api&v=2&key=ABQIAAAA_wv_4fNQXqbDmK8uXDPT4RS9Sno1k1HZ50fKzSL6k_Xo9VwKFRTEUFPMJm54Q8Sd8uANkz1nfIONvA" type="text/javascript"></script>
</head>
<body onload="initialize()" onunload="GUnload()">
<form action="#" onsubmit="setDirections(this.from.value, this.to.value, 'nl'); return false">
<table border="0">
<tr>
<td>Postcode: </td><td><input type="text" size="10" id="zoek_postcode" name="from"></td>
<td><input tabindex="1" name="submit" type="submit" value="Zoek"></td>
</tr>
</table>
<?php
require_once 'db_config.php';
$sql = "
SELECT
naam,
postcode
FROM
bedrijf
ORDER BY
naam ASC
";
if(!$res = mysql_query($sql))
{
trigger_error(mysql_error().'<br>In query: '.$sql);
}
elseif(mysql_num_rows($res) == 0)
{
echo 'Geen resultaten gevonden';
}
else
{
while($row = mysql_fetch_assoc($res))
{
echo 'Afstand naar '.$row['naam'].':<input type="hidden" id="test" name="to" value="'.$row['postcode'].'"></form><div id="afstand" style="font-weight: bold;"></div>';?>
<form action="#" onsubmit="setDirections(this.from.value, this.to.value, 'nl'); return false">
<table border="0">
<tr>
<td>Postcode: </td><td><input type="text" size="10" id="zoek_postcode" name="from"></td>
<td><input tabindex="1" name="submit" type="submit" value="Zoek"></td>
</tr>
</table>
<script type="text/javascript">
function initialize()
{
if (GBrowserIsCompatible())
{
// nieuw object ZONDER parameters, want we willen nl. geen geschreven route EN geen map tonen....
// http://code.google.com/apis/maps/documentation/reference.html#GDirections
gdir = new GDirections();
GEvent.addListener(gdir,"load", set_distance);
}
}
function setDirections(zoek_postcode, test, locale)
{
// http://code.google.com/apis/maps/documentation/reference.html#GDirectionsOptions
gdir.load("from: " + zoek_postcode + " to: " + test, {locale: locale, travelMode:G_TRAVEL_MODE_DRIVING,avoidHighways: false} );
}
function set_distance()
{
// extra: foutafhandeling, kan handig zijn!!!
handleErrors();
document.getElementById("afstand").innerHTML = gdir.getDistance().html;
}
function handleErrors()
{
// http://code.google.com/apis/maps/documentation/reference.html#GGeoStatusCode
if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_MISSING_QUERY || gdir.getStatus().code == G_GEO_MISSING_ADDRESS)
alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_BAD_KEY)
alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_UNAVAILABLE_ADDRESS)
alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_UNKNOWN_DIRECTIONS)
alert("The GDirections object could not compute directions between the points mentioned in the query. This is usually because there is no route available between the two points, or because we do not have data for routing in that region.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_TOO_MANY_QUERIES)
alert("The given key has gone over the requests limit in the 24 hour period or has submitted too many requests in too short a period of time.\n Error code: " + gdir.getStatus().code);
}
</script>
<?php
}
}
?>
</body>
</html>