Re: Integration einer Suchleiste mittels HTML-Code?
Geschrieben von thal1982 (Gast) am 17. Januar 2013 11:41:31: [flux]
Als Antwort auf:
Integration einer Suchleiste mittels HTML-Code?
geschrieben von
thal1982
(Gast)
am
02. Dezember 2012 20:50:
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