update map service

This commit is contained in:
j 2007-08-04 09:31:05 +00:00
parent 4d4f794fd0
commit 47785eff62
7 changed files with 77 additions and 20 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

80
map.php
View File

@ -1,14 +1,19 @@
<?php
set_time_limit(0);
error_reporting(0);
include('php/library.php');
$id = str_pad($_GET['id'], 7, '0', STR_PAD_LEFT);
$id = $_GET['id'];
if ($id == '')
die('map.php returns a map for a given IMDb id<br />usage: map.php?id=ID&q=QUERY<br />ID: IMDb id<br />QUERY: search term');
$id = str_pad($id, 7, '0', STR_PAD_LEFT);
$size = $_GET['size'];
if ($size != 'small')
$size = 'large';
$q = urldecode($_GET['q']);
$q = htmlentities($q);
if ($id == 0)
die('map.php returns a map for a given IMDb id<br />usage: map.php?id=ID&q=QUERY<br />ID: IMDb id<br />QUERY: search term');
$point = movie2locations($id);
@ -75,10 +80,20 @@ if ($point) {
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
HTML;
echo "var map = new GMap2(document.getElementById('map'));\n";
if ($size == 'large') {
echo <<<HTML
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
// map.addControl(new GOverviewMapControl());
HTML;
}
echo <<<HTML
var baseIcon = new GIcon();
baseIcon.shadow = 'http://services.0xdb.org/maps/png/markerShadow.png';
@ -116,8 +131,14 @@ HTML;
lngSpan = 360 - lngSpan;
// alert(spanLatitude + ' ' + spanLongitude + ' ' + zoom + ' ' + latSpan + ' ' + lngSpan);
}
HTML;
map.setMapType(G_HYBRID_MAP);
if ($size == 'small')
echo 'map.setMapType(G_SATELLITE_MAP);' . "\n";
else
echo 'map.setMapType(G_HYBRID_MAP);' . "\n";
echo <<<HTML
function createMarker(point, marker, label) {
var icon = new GIcon(baseIcon);
@ -125,9 +146,20 @@ HTML;
var marker = new GMarker(point, icon);
// label = label.replace(/ - /g, '<br />');
// label = label.replace(/, /g, '<br />');
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml('<span style="font-family: Helvetica, Arial; font-size: 13px">' + label + '</span>');
});
HTML;
if ($size == 'large') {
echo <<<HTML
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml('<span style="font-family: Helvetica, Arial; font-size: 13px">' + label + '</span>');
});
HTML;
}
echo <<<HTML
return marker;
}
createMarkers();
@ -202,7 +234,14 @@ HTML;
for (var i = 0; i < location.length; i++) {
var point = new GLatLng(latitude[i], longitude[i]);
map.addOverlay(createMarker(point, marker[i], location[i] + '<br /><span style="font-size: 10px">' + description[i] + '</span><span style="font-size: 10px">' + coordinates[i] + '</span>'));
HTML;
if ($size == 'small')
echo "map.addOverlay(createMarker(point, marker[i], ''))";
else
echo "map.addOverlay(createMarker(point, marker[i], location[i] + '<br /><span style=\"font-size: 10px\">' + description[i] + '</span><span style=\"font-size: 10px\">' + coordinates[i] + '</span>'));";
echo <<<HTML
}
}
@ -211,10 +250,16 @@ HTML;
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 808px; height: 505px; background: rgb(0, 0, 0)"></div>
HTML;
if ($size == 'small')
echo '<div id="map" style="width: 672px; height: 192px; background: rgb(0, 0, 0)"></div>';
else
echo '<div id="map" style="width:808px; height: 505px; background: rgb(0, 0, 0)"></div>';
echo <<<HTML
</body>
</html>
HTML;
}
@ -234,9 +279,18 @@ else {
</style>
</head>
<body>
<div id="map" style="width: 808px; height: 505px; background: url(png/map.png)"></div>
HTML;
if ($size == 'small')
echo "<div id=\"map\" style=\"width: 672px; height: 192px; background: url(png/mapSmall.png)\"></div>";
else
echo "<div id=\"map\" style=\"width:808px; height: 505px; background: url(png/mapLarge.png)\"></div>";
echo <<<HTML
</body>
</html>
HTML;
}

View File

@ -15,7 +15,8 @@ function movie2locations($id) {
$point = array();
$html = file_get_contents('http://imdb.com/title/tt' . $id . '/locations');
if (strlen($id) == 7)
$html = file_get_contents('http://imdb.com/title/tt' . $id . '/locations');
$string = explode('&&locations=', $html);
for ($i = 1; $i < count($string); $i++) {
@ -69,9 +70,11 @@ function movie2locations($id) {
// $locations_[$id] = $locations[$id];
// $locations = $locations_;
ksort($locations);
touch('data/locations.lock');
file_put_contents($file, serialize($locations));
unlink('data/locations.lock');
if (!file_exists('data/locations.lock')) {
touch('data/locations.lock');
file_put_contents($file, serialize($locations));
unlink('data/locations.lock');
}
}

BIN
png/mapLarge.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

BIN
png/mapSmall.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB