Integration einer Suchleiste mittels HTML-Code?

Moin,

ich weiß momentan nicht weiter,
für mein kleineres Projekt: http://www.ladegleis.de/ möchte ich noch ein Suchfeld integrieren.

Der Aufbau der Internetseite ist einfach gestaltet.
Wo kann man sich Beispiele von verschiedenen Codes für eine Integration eines Suchfeldes ansehen?
Alternative ist ein fertiger Code, aber dann lerne ich diesen Bestandteil nicht!

Bislang klappte alles sehr gut.

Ich sage schon im Vorwege: ,Danke".

Gruß

Thal

Schau mal, ob das da weiterhilft: http://wiki.openstreetmap.org/wiki/User:SunCobalt/OpenLayers_Suche
oder das da: http://forum.openstreetmap.org/viewtopic.php?id=17596

Grüße, Max

Das Beispiel hat mir nicht weiter geholfen.
Wie meinst du das, mmd?
Also braucht man doch nur ein Link (auf einer ,Adressdatei"), ein script-code (zur Einbindung in HTML) und eine leere Datei zum beschreiben(vermute ich einmal, war in dem Beispiel: ,SunCobalt", die csv-Datei).
Natürlich nicht zu vergessen: css-code.
Ich werde noch einmal weiter suchen.

Moin,

ich glaube ich brauche diesmal eine Anleitung.

Über Weihnachten hinüber konnte ich ein wenig herumtesten, aber es hat nichts genützt.

Vielleicht wäre es sinnvoll, eine andere Hilfe zu tätigen.

Der Startcode der index.html ist:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>www.ladegleis.de</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="content-script-type" content="text/javascript">
<meta http-equiv="content-style-type" content="text/css">
<meta http-equiv="content-language" content="de">
<meta name="author" content="Christian Thal">
<meta name="keywords" content="Ladegleis, Ladestelle, KLV, Containerterminals, Umschlagterminals, Umschlagterminal, Containerterminal, Ladegleise, Ladestellen, Startseite, Freiladegleis, Freiladegleise">
<link rel="stylesheet" type="text/css" href="ladegleis.css"><link>
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-36089111-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
</head>
<body>
<div id="header">
   <div id="content">Willkommen auf der Internetseite der Ladestellen/Umschlagterminals/Firmengleisanschlüsse</div>
   <div id="link">
   <br>Berichtigungsmitteilungen/Verbesserungen/Vorschläge einfach per E-Mail an mich: <a href="mailto:ladegleis@gmx.de">ladegleis@gmx.de</a></div>
   <div id="osm">©<a href="http://www.openstreetmap.org">OpenStreetMap</a>
     und <a href="http://www.openstreetmap.org/copyright">Mitwirkende</a>,
     <a href="http://creativecommons.org/licenses/by-sa/2.0/deed.de">CC-BY-SA</a>
   </div>
  </div>
<ul class="navbar">
  <li><a href="index.html">Startseite</a></li>
  <li><a href="Werbung.html">Werbung</a></li>
  <li><a href="Update.html">Update</a></li>
  <li><a href="Impressum.html">Impressum</a></li>
</ul>
<h3>Ladestellen:<br><img src="Ladestellen.png" alt="Ladestellenbild"><br><br>
Terminals:<br><img src="Terminal.png" alt="Terminalbild"><br><br>
Containerterminals:<br><img src="Containerterminal.png" alt="Containerterminalbild"><br><br>
Firmenanschlüsse:<br><img src="Firmenanschluss.png" alt="Firmenanschlussbild"><br><br>
Häfen:<br><img src="Hafen.png" alt="Hafenbild"><br><br>
Wer weiß mehr?:<br><img src="Fragezeichen.png" alt="Fragezeichenbild"><br></h3>
<div id="mapdiv"></div>
  <script src="http://www.openlayers.org/api/OpenLayers.js" type="text/javascript"></script>
  <script type="text/javascript">
    map = new OpenLayers.Map("mapdiv");
    map.addLayer(new OpenLayers.Layer.OSM());
 
var pois = new OpenLayers.Layer.Text( "My Points",
                    { location:"./DeutschlandContainerterminals.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points1",
                    { location:"./DeutschlandFirmenanschluss.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points2",
                    { location:"./DeutschlandHafen.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points3",
                    { location:"./DeutschlandLadestellen.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points4",
                    { location:"./DeutschlandTerminal.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points5",
                    { location:"./ItalienTerminals.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points5",
                    { location:"./PolenContainerterminals.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points5",
                    { location:"./SchweizTerminals.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
    //Set start centrepoint and zoom    
    var lonLat = new OpenLayers.LonLat( 9.755859375, 50.958426723359935 )
          .transform(
            new OpenLayers.Projection("EPSG:4326"),
            map.getProjectionObject() 
          );
    var zoom=5;
    map.setCenter (lonLat, zoom);  
 
  </script>
</body>
</html>

Wo, und wie muss ich welche Ergänzungen tätigen?
Und Warum?

So würde mir wenigstens geholfen werden können und durch mein nachfragen würde doch eine stetige kleinere Hilfe auch für andere aufgebaut werden.

Gruß

Thal

Man kann - aber bei einer wachsenden (bzw. unbekannten) Datenmenge ist das ein Unding, da vorab die komplette Datenbank (in diesem Fall plain text Dateien) zuerst zum Anwender übertragen werden muss (und dort aktuell in unzählige JS Objekte gewandelt und eingetragen werden). In diesem Beispiel hat eine einzige solche Datei 170 kB (http://www.ladegleis.de/DeutschlandLadestellen.txt - es sind hier aber noch weitere durchsuchbare Dateien vorhanden, die geladen werden). Das sind Mengen, bei denen die serverseitige Suche auf einer Datenbank dringend anzuraten ist. Zumal hunderte sich überlappende Grafiken keinen Sinn machen. Auch hinsichtlich zukünftigen Ausbauten macht es Sinn, sogleich eine “große” Lösung anzugehen.

Klar weiß auch ich, dass 170 kB heute in den meisten Fällen flott übertragen sind. Guter Stil ist das aber nicht. Und manche zahlen auch Volumentarife, wohnen in Dorf XYZ, verwenden IE7 auf nem 800MHz Rechner usw… Hier sind Webtechniken gefragt, bei deren Umsetzung auch viele “Profis” kein sauberes Ergebnis zustande bringen.

die karte ist ganz interessant. sind die ladestellen aus osm oder dient osm nur als basiskarte?

falls aus osm: welche keys werden ausgewertet?

Moin,

zuerst die Antwort auf die Frage von RvdtG:

OSM dient nur als Basiskarte zum Anzeigen der Standorte.
Die TXT-Dateien habe ich einfach bevorzugt (am Anfang habe ich auch mit CSV-Dateien herum experementiert).

Antwort zu MMD:
CSV-Dateien benutze ich nicht, TXT-Dateien.
Der Aufbau einer Ortssuche sollte in etwa so aussehen:
In der index.html-Datei ist der Link vorhanden für die Adressen (auf einen anderen Server:Nomination).
Desweiteren der Aufbau von Nomination-Adresssuchleiste.
Ein neuer Marker zur Lokalisierung für die Adresse.
Eine Datei zum speichern der Ergebnisse und zum Anzeigen der Ergebnisse in einer extra Spalte (Ausschaltbar).
Dies ist meine Vorstellung.

Antwort zu Joachim Moskalewski:
Die Datenmenge ist gering, eine Datenbank wäre irgendwann sinnvoll.
Ich finde das Laden bei der dynamischen CSV-Datei bei Netzwolf (die vielen Schatztruhen) zu lange.

Gruß

Thal

Moin,

ich habe jetzt den code etwas weiter angepasst.

Meine Fragen hierzu:
Steht der Link:

<script src="http://nominatim.openstreetmap.org/search?" type="text/javascript"></script>

an der richtigen Stelle in der index.html?

Wo muß man Format=xml eingeben (Speicherung der Suchergebnisse)?

Die Searchbox habe ich einmal mit dem Code:

<div id="search">
  <input type="text" name="addr" value="" id="addr" size="10" />
  <button type="button" onclick="addr_search();">Test</button>
  <div id="results"/>
</div>

auch hinzugefügt.

In der CSS-Datei habe ich einfach dieses noch angehängt (für die Gestaltung und wo es stehen soll, für die Search-Box):

div#search {
  background-color: white;
  position: absolute;
  bottom: 60px;
  left: 10px;
  width: auto;
  height: auto;
  padding: 10px;
}

div#search input {
  width: 80px;
}

div#results {
  font-style: sans-serif;
  color: black;
  font-size: 75%;
}

Der gesamte Code für die index.html ist dann momentan:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>www.ladegleis.de</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="content-script-type" content="text/javascript">
<meta http-equiv="content-style-type" content="text/css">
<meta http-equiv="content-language" content="de">
<meta name="author" content="Christian Thal">
<meta name="geo.region" content="DE-NI" />
<meta name="geo.placename" content="Buchholz" />
<meta name="geo.position" content="53.320005;9.859704" />
<meta name="ICBM" content="53.320005, 9.859704" />
<meta name="keywords" content="Ladegleis, Ladestelle, KLV, Containerterminals, Umschlagterminals, Umschlagterminal, Containerterminal, Ladegleise, Ladestellen, Startseite, Freiladegleis, Freiladegleise">
<link rel="stylesheet" type="text/css" href="ladegleis.css"><link>
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-36089111-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
</head>
<body>
<div id="header">
   <div id="content">Willkommen auf der Internetseite der Ladestellen/Umschlagterminals/Firmengleisanschlüsse</div>
   <div id="link">
   <br>Berichtigungsmitteilungen/Verbesserungen/Vorschläge einfach per E-Mail an mich: <a href="mailto:ladegleis@gmx.de">ladegleis@gmx.de</a></div>
   <div id="osm">©<a href="http://www.openstreetmap.org">OpenStreetMap</a>
     und <a href="http://www.openstreetmap.org/copyright">Mitwirkende</a>,
     <a href="http://creativecommons.org/licenses/by-sa/2.0/deed.de">CC-BY-SA</a>
   </div>
  </div>
<ul class="navbar">
  <li><a href="index.html">Startseite</a></li>
  <li><a href="Werbung.html">Werbung</a></li>
  <li><a href="Update.html">Update</a></li>
  <li><a href="Impressum.html">Impressum</a></li>
</ul>
<h3>Ladestellen:<br><img src="Ladestellen.png" alt="Ladestellenbild"><br><br>
Terminals:<br><img src="Terminal.png" alt="Terminalbild"><br><br>
Containerterminals:<br><img src="Containerterminal.png" alt="Containerterminalbild"><br><br>
Firmenanschlüsse:<br><img src="Firmenanschluss.png" alt="Firmenanschlussbild"><br><br>
Häfen:<br><img src="Hafen.png" alt="Hafenbild"><br><br>
Wer weiß mehr?:<br><img src="Fragezeichen.png" alt="Fragezeichenbild"><br></h3>
<div id="mapdiv"></div>
<div id="search">
  <input type="text" name="addr" value="" id="addr" size="10" />
  <button type="button" onclick="addr_search();">Test</button>
  <div id="results"/>
</div>
  <script src="http://www.openlayers.org/api/OpenLayers.js" type="text/javascript"></script>
  <script src="http://nominatim.openstreetmap.org/search?" type="text/javascript"></script>
  <script type="text/javascript">
    map = new OpenLayers.Map("mapdiv");
    map.addLayer(new OpenLayers.Layer.OSM());
 
var pois = new OpenLayers.Layer.Text( "My Points",
                    { location:"./DeutschlandContainerterminals.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points1",
                    { location:"./DeutschlandFirmenanschluss.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points2",
                    { location:"./DeutschlandHafen.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points3",
                    { location:"./DeutschlandLadestellen.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points4",
                    { location:"./DeutschlandTerminal.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points5",
                    { location:"./ItalienTerminals.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points6",
                    { location:"./PolenContainerterminals.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points7",
                    { location:"./SchweizTerminals.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
    //Set start centrepoint and zoom    
    var lonLat = new OpenLayers.LonLat( 9.755859375, 50.958426723359935 )
          .transform(
            new OpenLayers.Projection("EPSG:4326"),
            map.getProjectionObject() 
          );
    var zoom=5;
    map.setCenter (lonLat, zoom);  
 
  </script>
</body>
</html>

Die neue css-Datei wäre dann wohl schon fertig:

html,body {
  background-color: #000000;
  height: 100%;
  width: 100%;
  margin: 1%; padding: 0;
  overflow: hidden;
}
 
a {
  color: #FF0033;
}
 
a:hover {
  color: #FF0033;
  text-decoration: underline;
}

h1 {
  font-family: Verdana, Arial;
  font-size: 1em;
  color: #000000;
}

h2 {
  font-family: Verdana, Arial;
  font-size: 0.7em;
  color: #000000;
}

h2 li: {
  color: #FF0033;
  text-decoration: none;
}

#header {
  font-family: Verdana, Arial;
  overflow: hidden;
  color: #ffffff;
  text-align: center;
}
 
#mapdiv {
  position:absolute;
	top:150px;
	left:200px;
	width:80%;
	height:80%;
        padding: 0; margin: 0;
}
 
#content {
  font-size: 1em;
}
 
#osm {
  font-size: 0.7em;
  font-style: italic;
  margin-bottom: 20px;
}

#link {
  font-size: 0.7em;
  font-style: italic;
  margin-bottom: 20px;
}

ul.navbar {
  list-style-type: none;
  padding: 0;
  margin: 0;
  position: absolute;
  top: 2em;
  left: 1em;
  width: 9em }

ul.navbar li {
  background: white;
  margin: 0.5em 0;
  padding: 0.3em;
  border-right: 1em solid black }

ul.navbar a {
  text-decoration: none }

h3 {
  font-family: Verdana, Arial;
  font-size: 0.5em;
  color: #FFFFFF;
  margin-left: 2px;
  margin-top: 6%;
}

div#search {
  background-color: white;
  position: absolute;
  bottom: 60px;
  left: 10px;
  width: auto;
  height: auto;
  padding: 10px;
}

div#search input {
  width: 80px;
}

div#results {
  font-style: sans-serif;
  color: black;
  font-size: 75%;
}

Wie verlinkt man die Searchbox mit einer neuen xml-Datei?

Gruß

Thal

PS: Ich versuche es einfach zu lernen, schwere Materie.

Nahmd,

Man kann.

Gruß Wolf

Auch das ist eine Suche mit serverseitigem Script. Nur eben kein selbstgschriebenes auf dem eigenen Server. Es wird auch nicht “im Browser” gesucht. Ich bleibe bei meiner Aussage: Will man ohne serverseitigem Script bzw. im Browser suchen, muss die zu durchsuchende Datenbank vorab zum Webseitenbesucher transportiert werden (in welcher Form auch immer - CSV, XML; plain text usw.). Nur sinnvoll bei einer sehr geringen und nicht wachsenden Datenmenge (und auch dann würde ich weder Mühe noch Zeit in eine solche Sackgassenlösung stecken).

]Moins,

Hmm…

Also die Such-Engine von Nominatim als “Script” zu bezeichnen halte ich für mutig. Dito die Overpass-Engine wie auch den zentralen OSM-Datenbank-Server. Bei diesen Webdiensten denke ich eher an das als an ein Skript.

Selbstverständlich braucht jede nichttriviale™ Suche eine Suchengine, die die eigentliche Suche durchführt. Weil das Sicherheitskonzept “Same-Domain-Policy” dem JavaScript das Abschicken von XmlHttpRequest-Anfragen nur an den Server erlaubt, von dem die HTML-Seite geladen wurde, bietet sich die Nutzung eines “Proxy”-Scriptes auf dem eigenen Webserver an, das die Anfrage vom Script an die Suchengine weiterleitet und deren Antwort an das Script zurückreicht, und so die Einschränkung umgeht.

Wenn der eigene Webserver aber die Daten nur durchreicht, und wenn der Suchdienst das JSONP-Format bei der Antwort anbietet, dann kann man auf das Proxyscript verzichten und bekommt eine schlankere Lösung: ein zusätzliches Script einbinden, wenige Zeilen JS hinzufügen, mit ein paar Zeilen CSS die Suchleiste positionieren und stylen, und … schon hat die eigene Seite eine Suchleiste!

Die Welt ist und die Menschen darin sind immer bunter als man es sich vorstellt und als man es sich vorstellen kann. Möglicherweise ist die Sackgassenlösung genau das, was jemand sucht? Suche im Inhalt einer Seite als Alternative zu einer unendlichen Select-Box?

Gruß Wolf

Wow, echt coole arbeit :slight_smile:

Moin,

nun hat es doch einmal geklappt.
Großes Dankeschön an euch allen und an Netzwolf (durch dein Code kam ich weiter).

Vorher sah er ja so aus (Ausgangslage):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>www.ladegleis.de</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="content-script-type" content="text/javascript">
<meta http-equiv="content-style-type" content="text/css">
<meta http-equiv="content-language" content="de">
<meta name="author" content="Christian Thal">
<meta name="geo.region" content="DE-NI" />
<meta name="geo.placename" content="Buchholz" />
<meta name="geo.position" content="53.320005;9.859704" />
<meta name="ICBM" content="53.320005, 9.859704" />
<meta name="keywords" content="Ladegleis, Ladestelle, KLV, Containerterminals, Umschlagterminals, Umschlagterminal, Containerterminal, Ladegleise, Ladestellen, Startseite, Freiladegleis, Freiladegleise">
<link rel="stylesheet" type="text/css" href="ladegleis.css"><link>
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-36089111-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
</head>
<body>
<div id="header">
   <div id="content">Willkommen auf der Internetseite der Ladestellen/Umschlagterminals/Firmengleisanschlüsse</div>
   <div id="link">
   <br>Berichtigungsmitteilungen/Verbesserungen/Vorschläge einfach per E-Mail an mich: <a href="mailto:ladegleis@gmx.de">ladegleis@gmx.de</a></div>
   <div id="osm">©<a href="http://www.openstreetmap.org">OpenStreetMap</a>
     und <a href="http://www.openstreetmap.org/copyright">Mitwirkende</a>,
     <a href="http://creativecommons.org/licenses/by-sa/2.0/deed.de">CC-BY-SA</a>
   </div>
  </div>
<ul class="navbar">
  <li><a href="index.html">Startseite</a></li>
  <li><a href="Werbung.html">Werbung</a></li>
  <li><a href="Update.html">Update</a></li>
  <li><a href="Impressum.html">Impressum</a></li>
</ul>
<h3>Ladestellen:<br><img src="Ladestellen.png" alt="Ladestellenbild"><br><br>
Terminals:<br><img src="Terminal.png" alt="Terminalbild"><br><br>
Containerterminals:<br><img src="Containerterminal.png" alt="Containerterminalbild"><br><br>
Firmenanschlüsse:<br><img src="Firmenanschluss.png" alt="Firmenanschlussbild"><br><br>
Häfen:<br><img src="Hafen.png" alt="Hafenbild"><br><br>
Wer weiß mehr?:<br><img src="Fragezeichen.png" alt="Fragezeichenbild"><br></h3>
<div id="mapdiv"></div>
  <script src="http://www.openlayers.org/api/OpenLayers.js" type="text/javascript"></script>
  <script type="text/javascript" src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script>
  <script type="text/javascript">
    map = new OpenLayers.Map("mapdiv");
    map.addLayer(new OpenLayers.Layer.OSM());
 
var pois = new OpenLayers.Layer.Text( "My Points",
                    { location:"./DeutschlandContainerterminals.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points1",
                    { location:"./DeutschlandFirmenanschluss.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points2",
                    { location:"./DeutschlandHafen.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points3",
                    { location:"./DeutschlandLadestellen.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points4",
                    { location:"./DeutschlandTerminal.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points5",
                    { location:"./ItalienTerminals.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points6",
                    { location:"./PolenContainerterminals.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points7",
                    { location:"./SchweizTerminals.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
    //Set start centrepoint and zoom    
    var lonLat = new OpenLayers.LonLat( 9.755859375, 50.958426723359935 )
          .transform(
            new OpenLayers.Projection("EPSG:4326"),
            map.getProjectionObject() 
          );
    var zoom=5;
    map.setCenter (lonLat, zoom);  
 
  </script>
</body>
</html>

Danach so (im jetztigen Moment):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>www.ladegleis.de</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="content-script-type" content="text/javascript">
<meta http-equiv="content-style-type" content="text/css">
<meta http-equiv="content-language" content="de">
<meta name="author" content="Christian Thal">
<meta name="geo.region" content="DE-NI" />
<meta name="geo.placename" content="Buchholz" />
<meta name="geo.position" content="53.320005;9.859704" />
<meta name="ICBM" content="53.320005, 9.859704" />
<meta name="keywords" content="Ladegleis, Ladestelle, KLV, Containerterminals, Umschlagterminals, Umschlagterminal, Containerterminal, Ladegleise, Ladestellen, Startseite, Freiladegleis, Freiladegleise">
<link rel="stylesheet" type="text/css" href="ladegleis.css"><link>
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-36089111-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
</head>
<body>
<div id="header">
   <div id="content">Willkommen auf der Internetseite der Ladestellen/Umschlagterminals/Firmengleisanschlüsse</div>
   <div id="link">
   <br>Berichtigungsmitteilungen/Verbesserungen/Vorschläge einfach per E-Mail an mich: <a href="mailto:ladegleis@gmx.de">ladegleis@gmx.de</a></div>
   <div id="osm">©<a href="http://www.openstreetmap.org">OpenStreetMap</a>
     und <a href="http://www.openstreetmap.org/copyright">Mitwirkende</a>,
     <a href="http://creativecommons.org/licenses/by-sa/2.0/deed.de">CC-BY-SA</a>
   </div>
  </div>
<ul class="navbar">
  <li><a href="index.html">Startseite</a></li>
  <li><a href="Werbung.html">Werbung</a></li>
  <li><a href="Update.html">Update</a></li>
  <li><a href="Impressum.html">Impressum</a></li>
</ul>
<h3>Ladestellen:<br><img src="Ladestellen.png" alt="Ladestellenbild"><br><br>
Terminals:<br><img src="Terminal.png" alt="Terminalbild"><br><br>
Containerterminals:<br><img src="Containerterminal.png" alt="Containerterminalbild"><br><br>
Firmenanschlüsse:<br><img src="Firmenanschluss.png" alt="Firmenanschlussbild"><br><br>
Häfen:<br><img src="Hafen.png" alt="Hafenbild"><br><br>
Wer weiß mehr?:<br><img src="Fragezeichen.png" alt="Fragezeichenbild"><br></h3>
<div id="mapdiv"></div>
  <script type="text/javascript" src="http://www.openlayers.org/api/OpenLayers.js"></script>
  <script type="text/javascript" src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script>
  <script type="text/javascript" src="searchbox.js"></script>
  <script type="text/javascript" src="nominatim_translation_de.js"></script>
  <script type="text/javascript">
var map;

    map = new OpenLayers.Map("mapdiv");
    map.addLayer(new OpenLayers.Layer.OSM());

window.onload = function () 

	map.addControl (new OpenLayers.Control.SearchBox({
		resultMinZoom: 16
	}));

var pois = new OpenLayers.Layer.Text( "My Points",
                    { location:"./DeutschlandContainerterminals.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points1",
                    { location:"./DeutschlandFirmenanschluss.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points2",
                    { location:"./DeutschlandHafen.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points3",
                    { location:"./DeutschlandLadestellen.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points4",
                    { location:"./DeutschlandTerminal.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points5",
                    { location:"./ItalienTerminals.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points6",
                    { location:"./PolenContainerterminals.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
var pois = new OpenLayers.Layer.Text( "My Points7",
                    { location:"./SchweizTerminals.txt",
                      projection: map.displayProjection
                    });
    map.addLayer(pois);
    //Set start centrepoint and zoom    
    var lonLat = new OpenLayers.LonLat( 9.755859375, 50.958426723359935 )
          .transform(
            new OpenLayers.Projection("EPSG:4326"),
            map.getProjectionObject() 
          );
    var zoom=5;
    map.setCenter (lonLat, zoom);  
 
</script>
</body>
</html>

Ich habe einmal dieses eingefügt (in die HTML-Datei):

<script type="text/javascript" src="searchbox.js"></script>
<script type="text/javascript" src="nominatim_translation_de.js"></script>

und

var map;

sowie

window.onload = function () 

	map.addControl (new OpenLayers.Control.SearchBox({
		resultMinZoom: 16
	}));

Danach noch die beiden Dateien auch auf den Server kopiert (searchbox.js und nominatim_translation_de.js).

In der CSS-Datei habe ich nur dieses noch eingefügt:

.olControlSearchBox {
	left: 50px;
	top: 5px;
}

.olControlSearchBox div.busy {
	background: url(ajax-loader.gif);
	height: 55px;
	width: 54px;
}

.olControlSearchBox div.failure {
	background: red;
	color: black;
	font-weight: bold;
}

.olControlSearchBox div.success {
	background: white;
}

.olControlSearchBox div.success.empty {
	color: gray;
	font-style: italic;
}

.olControlSearchBox div.success div.entry:hover {
	background: blue;
	color: white;
	cursor: pointer;
}

Danach war es perfekt - es funktioniert.

Eine Frage fällt mir ein, warum wird den darauf verlinkt: url(ajax-loader.gif)?
Oder kann man das was in den Klammern steht weg machen, ohne Gedanken?

Gruß

Thal

Nahmd,

Bitte hole beide noch einmal ab, die sind etwas überarbeitet und aufgeräumt.

Mit “background: url(graphic.gif)” kann man ein Element mit einer Hintergrundgraphik versehen. An dieser Stelle zeige ich das “Nachlade-Symbol”, während ich auf die Antwort des Servers warte.

Ohne den Inhalt der Klammer wäre die Zeile ungültig. Wenn Du keine Suchstatusanzeige wünschst, kannst Du aber natürlich die gesamte Regel tilgen.

Ich verwende gerne diese Konstruktion, im Skript einem Element nur eine Klasse zuzuweisen, und den Rest per CSS zu erledigen. So kannst Du das Aussehen frei bestimmen, ohne im Script herumpatchen zu müssen.

Gruß Wolf

Nahmd,

JavaScript ist klassenlos, dennoch ist “class” ist ein Schlüsselwort und taugt nicht wirklich als Feldselektor; der IE bemängelt das vollkommen zu recht. Ist gefixt. Manchmal könnte ich den FF (oder dessen Entwickler) für ihre Nachsichtigkeit treten. :roll_eyes:

Selbiger Fehler hatte bereits bei dem Code für die Openinghours zugeschlagen:


switch (wochentag) {
case so: ...; break;
case mo: ...; break;
case di: ...; break;
case mi: ...; break;
case do: ...; break;
case fr: ...; break;
case sa: ...; break;
}

Wer findet den Fehler? :confused:

In der Tat ist CORS die elegante Lösung für den Zugriff auf Drittserver. Da aber nur ein Teil der Browser CORS unterstützt und das auch noch über zwei verschiedene Interfaces, ich also einen Teil der Nutzer aussperrte; da mir bei einer reinen Suche der Lesezugriff per GET-Protokoll reicht; und da ich außerdem eine möglichst einfache Lösung suche: welchen Vorteil bietet CORS da genau?

Schön wäre, wenn Du eine “cors_suchbox.js” ins Netz stellst. Die sollte im Browser einen niedrigeren Verwaltungsoverhead verursachen und signifikant schneller sein als das zwar originelle, aber auch reichlich kranke Anlegen und Zerstören von -Elementen bei der JSONP-Methode.

Gruß Wolf

fehlende “”???

Nahmd,

Case-Labels, die den Syntaxregeln für Bezeichner genügen (also insbesonders keine Leerzeichen oder Sonderzeichen enthalten) brauchen nicht gequotet zu werden. Das macht den Code leserlicher. Aber: Keywords sind keine Identifier. Und eine der Wochentagsabkürzungen ist ein Keyword :confused:

Der IE mäkelts an. Der FF lässts durchgehen. Wobei letzteres keine Entschuldigung ist: man kann/sollte den Code durch einen Syntaxchecker/Lint jagen, bevor man ihn auf die Menschheit loslässt.

Gruß Wolf

wer jongliert mit Wochentagsabkürzungen? in vba haben die Wochentage ne Nummer… 1,2,3,4,5,6,7 oder so :smiley:

Switch(intWeekday = 1, "Sonntag", intWeekday = 2, _
        "Montag", intWeekday = 3, "Dienstag", intWeekday = 4, _
        "Mittwoch", intWeekday = 5, "Donnerstag", intWeekday = 6, _
        "Freitag", intWeekday = 7, "Samstag") 

Nahmd,

Die Fehlerkorrekturkomponente der Auswertung von “opening_hours”, genauer die Ersetzung von nicht englisch geschriebener Wochentagsnamen; suche einfach nach “donnerstag”.

Bisher gibt es eine Implementierung in JavaScript und eine in PHP: VBA fehlt noch.
Dich hier als VBA-Experten zu outen war ein Fehler :stuck_out_tongue:

Gruß Wolf

Moin,

die searchbox.js ist doch weiter angewachsen (in den Zeilenmengen) sowie die nominatim_translation_de.js.

Rein theoretisch könnte man noch die blauen Felder löschen:

//------------------------------------------------------------------------------
//	$Id: nominatim_translation_de.js,v 1.7 2013/01/16 17:21:53 wolf Exp $
//------------------------------------------------------------------------------
//	Deutsche Uebersetzung der von Nominatim gelieferten class und type Werte.
//	Schamlos gestohlen von:
//	http://wiki.openstreetmap.org/wiki/User:SunCobalt/OpenLayers_Suche
//------------------------------------------------------------------------------

if (!OpenLayers.NominatimTranslation) { OpenLayers.NominatimTranslation = {}; }

OpenLayers.NominatimTranslation.de = {
	'aerialway.cable_car':	'Seilbahn',
	'aerialway.gondola':	'Gondelbahn',
	'aerialway.goods':	'Materialseilbahn',
	'aerialway.station':	'Seilbahnstation',
	'aeroway.aerodrome':	'Flughafen',
	'aeroway.runway':	'Start-/Landebahn',
	'amenity.arts_centre':	'Kunstzentrum',
	'amenity.atm':	'Geldautomat',
	'amenity.bank':	'Bank (Geldinstitut)',
	'amenity.bar':	'Bar',
	'amenity.bbq':	'Grillplatz',
	'amenity.bench':	'Bank (Sitzgelegenheit)',
	'amenity.biergarten':	'Biergarten',
	'amenity.brothel':	'Bordell',
	'amenity.cafe':	'Cafe',
	'amenity.car_rental':	'Autovermietung',
	'amenity.cinema':	'Kino',
	'amenity.college':	'Hochschule',
	'amenity.community_centre':	'B'+String.fromCharCode(252)+'rgerzentrum',
	'amenity.courthouse':	'Gericht',
	'amenity.diving:center':	'Tauchzentrum',
	'amenity.drinking_water':	'Trinkwasser',
	'amenity.embassy':	'Botschaft',
	'amenity.fast_food':	'Fast-Food',
	'amenity.ferry_terminal':	'F'+String.fromCharCode(228)+'hrterminal',
	'amenity.fire_station':	'Feuerwache',
	'amenity.fuel':	'Tankstelle',
	'amenity.grave_yard':	'Friedhof',
	'amenity.hospital':	'Krankenhaus',
	'amenity.hunting_stand':	'Hochsitz',
	'amenity.kindergarten':	'Kindergarten',
	'amenity.library':	'Bibliothek',
	'amenity.nightclub':	'Nachtclub',
	'amenity.parking':	'Parkplatz',
	'amenity.pharmacy':	'Apotheke',
	'amenity.place_of_worship':	'Gotteshaus',
	'amenity.police':	'Polizei',
	'amenity.post_office':	'Postamt',
	'amenity.prison':	'Gef'+String.fromCharCode(228)+'ngnis',
	'amenity.pub':	'Kneipe',
	'amenity.public_building': 	String.fromCharCode(246)+'ffentl. Geb'+String.fromCharCode(228)+'ude',
	'amenity.recycling':	'Recycling',
	'amenity.restaurant':	'Restaurant',
	'amenity.school':	'Schule',
	'amenity.shelter':	'Unterstand',
	'amenity.social_centre':	'Soziale Einrichtung',
	'amenity.social_facility':	'Soziale Einrichtung',
	'amenity.swimming_pool':	'Schwimmbad',
	'amenity.taxi':	'Taxi',
	'amenity.theatre':	'Theater',
	'amenity.townhall':	'Rathaus',
	'amenity.university':	'Universit'+String.fromCharCode(228)+'t',
	'barrier.city_wall':	'Stadtmauer',
	'barrier.toll_booth':	'Mautstelle',
	'boundary.administrative':	'Verwaltungsgrenze',
	'boundary.national_park':	'Nationalparksgrenze',
	'bridge.yes':	'Br'+String.fromCharCode(252)+'cke',
	'building.yes':	'Geb'+String.fromCharCode(228)+'ude',
	'highway.bridleway':	'Reitweg',
	'highway.bus_station':	'Busbahnhof',
	'highway.bus_stop':	'Bushaltestelle',
	'highway.crossing':	'Kreuzung',
	'highway.cycleway':	'Radweg',
	'highway.footway':	'Fu'+String.fromCharCode(223)+'weg',
	'highway.ladder':	'Leiter',
	'highway.living_street':	'Stra'+String.fromCharCode(223)+'e',
	'highway.motorway':	'Autobahn',
	'highway.motorway_junction':	'Autobahnkreuz',
	'highway.motorway_link':	'Autobahnauffahrt',
	'highway.path':	'Pfad',
	'highway.pedestrian':	'Fu'+String.fromCharCode(223)+'g'+String.fromCharCode(228)+'ngerzone',
	'highway.platform':	'Bahnsteig',
	'highway.primary':	'Stra'+String.fromCharCode(223)+'e',
	'highway.primary_link':	'Stra'+String.fromCharCode(223)+'e',
	'highway.raceway':	'Rennstrecke(Raceway)',
	'highway.residential':	'Wohnstra'+String.fromCharCode(223)+'e', // Konflikt zu Wohngebiet
	'highway.road':	'Stra'+String.fromCharCode(223)+'e',
	'highway.secondary':	'Stra'+String.fromCharCode(223)+'e',
	'highway.secondary_link':	'Stra'+String.fromCharCode(223)+'e',
	'highway.service':	'Zufahrt',
	'highway.steps':	'Treppe',
	'highway.tertiary':	'Stra'+String.fromCharCode(223)+'e',
	'highway.tertiary_link':	'Stra'+String.fromCharCode(223)+'e',
	'highway.track':	'Feldweg',
	'highway.trunk':	'Schnellstra'+String.fromCharCode(223)+'e',
	'highway.unclassified':	'Stra'+String.fromCharCode(223)+'e',
	'historic.archaeolocical_site':	'Arch'+String.fromCharCode(228)+'ologische St'+String.fromCharCode(228)+'tte',
	'historic.castle':	'Burg',
	'historic.heritage':	'Kulturerbe',
	'historic.memorial':	'Gedenkst'+String.fromCharCode(228)+'tte',
	'historic.monument':	'Denkmal',
	'historic.tower':	'Historischer Turm',
	'landuse.allotments':	'Kleing'+String.fromCharCode(228)+'rten',
	'landuse.basin':	'Wasserbasin',
	'landuse.brownfield':	'Brachland',
	'landuse.cemetery':	'Friedhof',
	'landuse.commercial':	'Gewerbegebiet',
	'landuse.conservation':	'Schutzgebiet',
	'landuse.construction':	'Baugebiet',
	'landuse.farm':	'Bauernhof (Farm)',
	'landuse.farmyard':	'Bauernhof (Farmyard)',
	'landuse.forest':	'Wald',
	'landuse.grass':	'Gras',
	'landuse.greenfield':	'Bauerwartungsland',
	'landuse.industrial':	'Industriegebiet',
	'landuse.landfill':	'Deponie',
	'landuse.meadow':	'Weide',
	'landuse.recreation_ground':	'Freizeitgel'+String.fromCharCode(228)+'nde',
	'landuse.residential':	'Wohngebiet',
	'landuse.retail':	'Einkaufsgegend',
	'landuse.village_green':	'Dorfanger',
	'leisure.club':	'Klub',
	'leisure.garden':	'Garten',
	'leisure.golf_course':	'Golfplatz',
	'leisure.ice_rink':	'Eisbahn',
	'leisure.marina':	'Yachthafen',
	'leisure.military':	'Militärgel'+String.fromCharCode(228)+'nde',
	'leisure.miniature_golf':	'Mini-Golf',
	'leisure.nature_reserve':	'Naturschutzgebiet',
	'leisure.park':	'Park',
	'leisure.pitch':	'Spielfeld',
	'leisure.playground':	'Spielplatz',
	'leisure.quarry':	'Steinbruch',
	'leisure.sports_centre':	'Sportzentrum',
	'leisure.stadium':	'Stadion',
	'leisure.swimming_pool':	'Swimmingpool',
	'leisure.theme_park':	'Freizeitpark',
	'leisure.track':	'Rennstrecke(Track)',
	'leisure.water_park':	'Wasserpark',
	'man_made.cairn':	'Steinmanderl',
	'man_made.pole':	'Stange',
	'natural.cave_entrance':	'H'+String.fromCharCode(246)+'hleneingang',
	'natural.cliff':	'Felswand',
	'natural.glacier':	'Gletscher',
	'natural.grassland':	'Steppe',
	'natural.heath':	'Heide',
	'natural.peak':	'Gipfel',
	'natural.scree':	'Ger'+String.fromCharCode(246)+'ll',
	'natural.scrub':	'Gestr'+String.fromCharCode(252)+'pp',
	'natural.spring':	'Quelle',
	'natural.water':	'Gew'+String.fromCharCode(228)+'sser',
	'natural.wetland':	'Feuchtgebiet',
	'natural.wood':	'Naturwald',
	'place.city':	'Stadt',
	'place.continent':	'Kontinent',
	'place.country':	'Staat',
	'place.county':	'Kreis',
	'place.hamlet':	'Weiler',
	'place.house':	'Haus',
	'place.island':	'Insel',
	'place.islet':	'Insel',
	'place.isolated_dwelling':	'Weiler',
	'place.locality':	'Ort',
	'place.mountain_pass':	'Gebirgspass',
	'place.neighbourhood':	'Nachbarschaft',
	'place.postcode':	'Postleitzahlbereich',
	'place.region':	'Region',
	'place.state':	'Staat',
	'place.suburb':	'Stadtteil',
	'place.town':	'Stadt',
	'place.village':	'Dorf',
	'railway.halt':	'Bahnhof',
	'railway.station':	'Bahnhof',
	'railway.tram_stop':	'Stra'+String.fromCharCode(223)+'enbahnhaltestelle',
	'shop.bakery':	'B'+String.fromCharCode(228)+'ckerei',
	'shop.beauty':	'Kosmetiksalon',
	'shop.beverages':	'Getr'+String.fromCharCode(228)+'nkemarkt',
	'shop.books':	'Buchhandlung',
	'shop.boutique':	'Boutique',
	'shop.butcher':	'Fleischer',
	'shop.car':	'Autohaus',
	'shop.car_repair':	'Autowerkstatt',
	'shop.chemist':	'Drogerie',
	'shop.clothes':	'Bekleidungsgesch'+String.fromCharCode(228)+'ft',
	'shop.computer':	'Computer-Laden',
	'shop.confectionery':	'S'+String.fromCharCode(252)+String.fromCharCode(223)+'warenh'+String.fromCharCode(228)+'ndler',
	'shop.convenience':	'Tante-Emma-Laden',
	'shop.department_store':	'Kaufhaus',
	'shop.doityourself':	'Baumarkt',
	'shop.dry_cleaning':	'Reinigung',
	'shop.electronics':	'Elektroladen',
	'shop.florist':	'Blumenladen',
	'shop.garden_centre':	'Garten-Center',
	'shop.greengrocer':	'Gem'+String.fromCharCode(252)+'se-H'+String.fromCharCode(228)+'ndler',
	'shop.hairdresser':	'Friseur',
	'shop.ice_cream':	'Eis-Cafe',
	'shop.jewelry':	'Juwelier',
	'shop.kiosk':	'Kiosk',
	'shop.laundry':	'Reinigung',
	'shop.mall':	'Einkaufszentrum',
	'shop.marketplace':	'Markt',
	'shop.mobile_phone':	'Handy-Shop',
	'shop.newsagent':	'Zeitungsh'+String.fromCharCode(228)+'ndler',
	'shop.organic':	'Bio-Laden',
	'shop.pet':	'Zoohandlung',
	'shop.retail':	'Einzelhandel',
	'shop.shoes':	'Schuhladen',
	'shop.stationery':	'Schreibwarenladen',
	'shop.supermarket':	'Supermarkt',
	'shop.tobacco':	'Tabakladen',
	'shop.toys':	'Spielzeugladen',
	'shop.yes':	'Gesch'+String.fromCharCode(228)+'ft',
	'tourism.alpine_hut':	'Bergh'+String.fromCharCode(252)+'tte',
	'tourism.artwork':	'Kunstwerk',
	'tourism.attraction':	'Attraktion',
	'tourism.basic_hut':	'Biwakh'+String.fromCharCode(252)+'tte',
	'tourism.camp_site':	'Campingplatz',
	'tourism.guest_house':	'Pension',
	'tourism.hotel':	'Hotel',
	'tourism.information':	'Information',
	'tourism.motel':	'Motel',
	'tourism.museum':	'Museum',
	'tourism.picnic_site':	'Piknikplatz',
	'tourism.viewpoint':	'Aussichtsturm',
	'tourism.zoo':	'Zoo',
	'tunnel.yes':	'Tunnel',
	'waterway.canal':	'Kanal',
	'waterway.dam':	'Damm',
	'waterway.river':	'Fluss',
	'waterway.riverbank':	'Flussfl'+String.fromCharCode(228)+'che',
	'waterway.stream':	'Bach',
	'waterway.waterfall':	'Wasserfall'
};
//------------------------------------------------------------------------------
//	$Id: nominatim_translation_de.js,v 1.7 2013/01/16 17:21:53 wolf Exp $
//------------------------------------------------------------------------------

bzw. :

//------------------------------------------------------------------------------
//	$Id: searchbox.js,v 1.12 2013/01/16 19:14:53 wolf Exp wolf $
//------------------------------------------------------------------------------
//	Erklaerung:	http://www.netzwolf.info/kartografie/openlayers/search.htm
//------------------------------------------------------------------------------
//	Fragen, Wuensche, Bedenken, Anregungen?
//	<openlayers(%40)netzwolf.info>
//------------------------------------------------------------------------------
OpenLayers.Control.SearchBox=OpenLayers.Class(OpenLayers.Control, {
	resultMinZoom: 12,
	lang: 'de',
	baseUrl: 'http://nominatim.openstreetmap.org/search?' +
			'format=json&json_callback={callback}&addressdetails=0&q={query}',
	destroy:function() {
		if (this.input) { stopObservingElement(this.input); }
		this.form  = null;
		this.input = null;
		this.resultDiv = null;
		OpenLayers.Control.prototype.destroy.apply(this,arguments);
	},
	draw:function(px) {
		OpenLayers.Control.prototype.draw.apply(this,arguments);
		this.input= document.createElement ('input');
		this.input.setAttribute('type', 'text');
		this.input.setAttribute('name', 'q');
		this.input.control=this;
		this.form=document.createElement ('form');
		this.form.style.display='inline';
		this.form.appendChild(this.input);
		this.form.control=this;
		this.form.onsubmit=this.formOnSubmit;
		this.resultDiv=document.createElement ('div');
		this.div.appendChild(this.form);
		this.div.appendChild(this.resultDiv);
		OpenLayers.Event.observe(this.input, 'click', this.inputClickEvent);
		return this.div;
	},
	inputClickEvent: function(evt) {
		evt.target.value='';
		evt.target.focus();
		evt.target.control.cancelSearch();
	},
	formOnSubmit: function() {
		this.control.startSearch(this.elements.q.value);
		return false;
	},
	currentRequest: null,
	startSearch: function (q) {
		this.cancelSearch();
		q = OpenLayers.String.trim(q);
		if (q==='') { return false; }
		this.resultDiv.className='busy';
		this.jsonpRequest (
			this.baseUrl.replace(/{query}/, encodeURIComponent(q)),
			this,
			this.success,
			this.failure,
			{timeout: 5000});
		return false;
	},
	cancelSearch: function () {
		if (this.currentRequest) { this.currentRequest.cancel(); }
		this.currentRequest = null;
		this.removeResult();
	},
	success: function (result) {
		this.currentRequest = null;
		this.removeResult();
		this.resultDiv.className='success';
		this.formatResult(result);
	},
	failure: function (message) {
		this.currentRequest = null;
		this.removeResult();
		this.resultDiv.className='failure';
		this.resultDiv.appendChild (document.createTextNode (message));
	},
	formatResult: function(result) {
		for (var i in result) {
			var element=this.formatResultEntry(data=result[i]);
			element.onclick=this.onResultEntryClick;
			element.className='entry';
			element.control=this;
			element.data=data;
			this.resultDiv.appendChild(element);
		}
		if (!result.length) {
			this.resultDiv.className='success empty';
			this.resultDiv.appendChild (document.createTextNode ('Kein Treffer.'));
		}
	},
	formatResultEntry: function(data) {
		var div = document.createElement ('div');
		div.setAttribute('title', data.display_name + ' [' + data['class'] + ', ' + data.type + ']');
		div.appendChild (document.createTextNode (
			data.display_name.split(', ').slice(0,2).join(', ') +
				' [' + this.translate(data['class'], data.type) + ']'));
		return div;
	},
	translate: function (clasz, type) {
		var dict = OpenLayers.NominatimTranslation && OpenLayers.NominatimTranslation[this.lang];
		var trans = dict && dict[clasz+'.'+type];
		if (trans) { return trans; }
		return clasz+'='+type;
	},
	onResultEntryClick: function() {
		var control = this.control;
		control.removeResult();
		var lonlat = new OpenLayers.LonLat(this.data.lon,this.data.lat).
        		transform(new OpenLayers.Projection("EPSG:4326"), control.map.getProjectionObject());
		if (control.map.getZoom()<control.resultMinZoom) {
			control.map.moveTo (lonlat, control.resultMinZoom);
		} else {
			control.map.panTo (lonlat);
		}
	},
	removeResult: function() {
		while (this.resultDiv.firstChild) {
			this.resultDiv.removeChild(this.resultDiv.firstChild);
		}
		this.resultDiv.className='';
	},
	jsonpRequest: function (url, scope, success, failure, options) {
		options=options||{};
		var id = 'jsonp' + new Date().getTime();
		url = url.replace(/{callback}/, 'window.' + id + '.callback');
		var scriptElement = document.createElement('script');
		scriptElement.setAttribute('type', 'text/javascript');
		scriptElement.setAttribute('src', url);
		var request = {
			id: id,
			scope: scope,
			success: success,
			failure: failure,
			callback: function (data) {
                        	this.cancel();
                        	this.success.apply(this.scope, [data]);
			},
			timeout: function () {
				this.cancel();
				this.failure.apply(this.scope, ['timeout']);
			},
			cancel: function() {
				window.clearTimeout(this.timer);
				if(this.scriptElement.parentElement) {
					this.scriptElement.parentElement.removeChild(this.scriptElement);
				}
				delete window[this.id];
			},
			scriptElement: scriptElement
		};
		request.timer = window.setTimeout (function(){request.timeout();},
			options.timeout || 5000);
		window[id] = request;
		document.getElementsByTagName('head')[0].appendChild(scriptElement);
		return request;
	},
	CLASS_NAME:'OpenLayers.Control.SearchBox'
});
//--------------------------------------------------------------------------------
//	$Id: searchbox.js,v 1.12 2013/01/16 19:14:53 wolf Exp wolf $
//--------------------------------------------------------------------------------

Dadurch käme man nur bei der letzten Datei auf 162 Zeilen…,bzw. auf 5,693 Bytes.

Gruß

Thal