På Københavns Universitet kører vi en relativt kompliceret implementering af google maps. Der findes en version på dansk og engelsk. Det er ved den engelske jeg har brug for hjælp.
Her ligger den
http://findvej.ku.dk/english/De individuelle steder - som man kan navigere frem til ude til højre - har flere attributes tilknyttet, herunder et link til Rejseplanen, så man kan finde vej.
Selve dette link til Rejseplanen hentes fra en ekstern xml-fil og loades ind via javascript her:
- case "Link_til_Rejseplan": tmpMarker[i].link_rejseplan = GXml.value(fields[j].getElementsByTagName("fieldvalue")[0]);
- break;
Jeg har behov for at modificere den url der hentes ind på den måde, at der bliver sat et /en/ ind lige efter query.exe, idet jeg så på den måde kan vise den engelsksprogede side i stedet for den dansksprogede.
Den fulde url til rejseplanen er:
http://www.rejseplanen.dk/bin/query.exe/mn?ZID=A=2@O=Gr%C3%B8nneg%C3%A5rdsvej%2015,%201870%20Frederiksberg%20C,%20Frederiksberg@X=12540994@Y=55681108@U=103@L=901470139@B=1@p=1285928069@&externalCall=yes&start=yesOg den skal så bagefter være
http://www.rejseplanen.dk/bin/query.exe/en/mn?ZID=A=2@O=Gr%C3%B8nneg%C3%A5rdsvej%2015,%201870%20Frederiksberg%20C,%20Frederiksberg@X=12540994@Y=55681108@U=103@L=901470139@B=1@p=1285928069@&externalCall=yes&start=yesDet fulde script kan ses herunder. Håber en kan hjælpe.
Mvh
Anders Peter Schultz
- <script type="text/javascript">
- var map;
- var tmpMarker = [];
- var gmarkers = [];
- var ii = 0;
- var tooltip;
-
-
-
- var markerCollection = [];
-
- var baseicon = new GIcon();
-
-
- $(document).ready(function () {
- if (GBrowserIsCompatible()){
-
- map = new GMap2(document.getElementById("mapDiv"));
-
- // setup custom pushpin icon
- baseicon.image = "http://findvej.ku.dk/img/mm_20_yellow.png";
- baseicon.shadow = "http://findvej.ku.dk/img/mm_20_shadow.png";
- baseicon.iconSize = new GSize(12, 20);
- baseicon.shadowSize = new GSize(22, 20);
- baseicon.iconAnchor = new GPoint(6, 20);
- baseicon.infoWindowAnchor = new GPoint(5, 1);
-
- /* map.addControl(new GLargeMapControl());
-
- map.addControl(new GScaleControl());*/
-
- //Set center of map to Frue Plads and view KU-map
- map.setCenter(new GLatLng(55.6858, 12.5654), 15);
-
- map.setUIToDefault();
-
- var url = "http://findvej.ku.dk/markers/?get_file=1";
-
- GDownloadUrl(url, function(data, responseCode){
- if (responseCode == 200) {
- var xmlDoc = GXml.parse(data);
- markers = xmlDoc.documentElement.getElementsByTagName("entry");
- for (var i = 0; i < markers.length; i++) {
- tmpMarker[i] = [];
- fieldcollection = markers[i].getElementsByTagName("fields");
- fields = fieldcollection[0].getElementsByTagName("field");
- for (var j = 0; j < fields.length; j++) {
- switch(GXml.value(fields[j].getElementsByTagName("fieldname")[0])) {
- case "Navn":
- tmpMarker[i].navn_dansk = GXml.value(fields[j].getElementsByTagName("fieldvalue")[0]);
- break;
- case "Kort_navn__akronym_":
- tmpMarker[i].akronym = GXml.value(fields[j].getElementsByTagName("fieldvalue")[0]);
- break;
- case "Navn__engelsk_":
- tmpMarker[i].navn_engelsk = GXml.value(fields[j].getElementsByTagName("fieldvalue")[0]);
- break;
- case "Fakultet_FA":
- tmpMarker[i].fakultet = GXml.value(fields[j].getElementsByTagName("fieldvalue")[0]);
- break;
- case "Adresse":
- tmpMarker[i].adresse = GXml.value(fields[j].getElementsByTagName("fieldvalue")[0]);
- break;
- case "Postnr_":
- tmpMarker[i].postnr = GXml.value(fields[j].getElementsByTagName("fieldvalue")[0]);
- break;
- case "By__Postdistrikt_":
- tmpMarker[i].by = GXml.value(fields[j].getElementsByTagName("fieldvalue")[0]);
- break;
- case "Enhedens_danske_website":
- tmpMarker[i].web_dansk = GXml.value(fields[j].getElementsByTagName("fieldvalue")[0]);
- break;
- case "Enhedens_engelske_website":
- tmpMarker[i].web_engelsk = GXml.value(fields[j].getElementsByTagName("fieldvalue")[0]);
- break;
- case "URL_til_billede":
- tmpMarker[i].url_billede = GXml.value(fields[j].getElementsByTagName("fieldvalue")[0]);
- break;
- case "Breddegrad__lat_":
- tmpMarker[i].lat = parseFloat(GXml.value(fields[j].getElementsByTagName("fieldvalue")[0]));
- break;
- case "L_ngdegrad__lng_":
- tmpMarker[i].lng = parseFloat(GXml.value(fields[j].getElementsByTagName("fieldvalue")[0]));
- break;
- case "Link_til_Rejseplan":
- tmpMarker[i].link_rejseplan = GXml.value(fields[j].getElementsByTagName("fieldvalue")[0]);
- break;
- case "Yderligere_information1":
- tmpMarker[i].yderligere_information = GXml.value(fields[j].getElementsByTagName("fieldvalue")[0]);
- break;
- }
- }
-
- var marker = createKUMarker(tmpMarker[i]);
- map.addOverlay(marker);
- //listUnits();
-
- }
- listUnits();
-
- }
- });
-
- //listUnits();
-
- function createKUMarker(tmpMarker) {
- var point = new GLatLng(tmpMarker.lat,tmpMarker.lng);
- markerOptions = { icon:baseicon };
- var marker = new GMarker(point,markerOptions);
- marker.tooltip = "<div class='tooltip'><nobr>" + tmpMarker.navn_engelsk + "</nobr></div>";
- var html = "<div class='infowindow'><h2 class='infowindow'>" + tmpMarker.navn_engelsk;
- if (tmpMarker.akronym != "") {
- html = html + " (" + tmpMarker.akronym + ")</h2>";
- } else {
- html = html + "</h1>";
- }
- html = html + "<table><tr><td>";
- if (tmpMarker.url_billede != "" || !tmpMarker.url_billede) {
- html = html + "<img style='width: 150px; height: 75px; border: 1px solid #000;' src='" + tmpMarker.url_billede + "' /> <td/>";
- }
- html = html + "<td style='vertical-align: top;'><p class='adresse'>" + tmpMarker.adresse + "<br />" + tmpMarker.postnr + " " + tmpMarker.by + "<p/></td></tr></table>";
- html = html + "<p class='rejseplanen'>Navigate with Journey Planner <a href='"+tmpMarker.link_rejseplan+"' target='_blank'><img src='http://cms.ku.dk/fa-sites/goomaps_final/img/RP_logo_RGB_transparant.gif' /></a></p>";
- if (tmpMarker.yderligere_information != "" || !tmpMarker.yderligere_information) {
- html = html + "<p class='description'>" + tmpMarker.yderligere_information;
- }
- if (tmpMarker.web_engelsk != "") {
- html = html + "<a href='" + tmpMarker.web_engelsk + "'>Visit webpage</a></p>";
- } else {
- html = html + "</p>";
- }
- GEvent.addListener(marker, "click", function() {
- marker.openInfoWindowHtml(html);
- });
- GEvent.addListener(marker,"mouseover", function() {
- showTooltip(marker);
- });
-
- GEvent.addListener(marker,"mouseout", function() {
- tooltip.style.visibility="hidden"
- });
- gmarkers[ii] = marker;
-
- switch (tmpMarker.fakultet) {
- case "ku":
- fillInTo = "ku";
- break;
- case "sund":
- fillInTo = "sund";
- break;
- case "life":
- fillInTo = "life";
- break;
- case "farma":
- fillInTo = "farma";
- break;
- case "hum":
- fillInTo = "hum";
- break;
- case "jur":
- fillInTo = "jur";
- break;
- case "nat":
- fillInTo = "nat";
- break;
- case "samf":
- fillInTo = "samf";
- break;
- case "teo":
- fillInTo = "teo";
- break;
- default:
- fillInTo = "andre";
- break;
- }
- fillInToDiv = document.getElementById(fillInTo);
- fillInToDiv.innerHTML += "<p><a href='javascript:return false' onclick='javascript:myclick(" + ii + ")' onmouseover='mymouseover(" + ii + ")' onmouseout='mymouseout()'>" + tmpMarker.navn_engelsk + "</a></p>";
-
-
-
- ii++;
- return marker;
- }
-
-
-
- tooltip = document.createElement("div");
- map.getPane(G_MAP_FLOAT_PANE).appendChild(tooltip);
- tooltip.style.visibility="hidden";
-
- function kml_toogle() {
- if (geoXmlVisible==1) {
- map.removeOverlay(geoXml);
- geoXmlVisible = 0;
- } else {
- map.addOverlay(geoXml);
- }
- }
-
- }
- });
-
- // ===== This function is invoked when the mouse goes over an entry in the side_bar =====
- // It launches the tooltip on the icon
- function mymouseover(i) {
- showTooltip(gmarkers[i])
- }
- // ===== This function is invoked when the mouse leaves an entry in the side_bar =====
- // It hides the tooltip
- function mymouseout() {
- tooltip.style.visibility="hidden";
- }
- // This function picks up the click and opens the corresponding info window
- function myclick(i) {
- GEvent.trigger(gmarkers[i], "click");
- window.location.hash = "#top";
-
-
- }
-
- function showTooltip(marker) {
- tooltip.innerHTML = marker.tooltip;
- var point=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.fromDivPixelToLatLng(new GPoint(0,0),true),map.getZoom());
- var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),map.getZoom());
- var anchor=marker.getIcon().iconAnchor;
- var width=marker.getIcon().iconSize.width;
- var height=tooltip.clientHeight;
- var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(offset.x - point.x - anchor.x + width, offset.y - point.y -anchor.y -height));
- pos.apply(tooltip);
- tooltip.style.visibility="visible";
- }
-
- // == Search function
- var searchTimerId = 0;
-
- function searchIt(searchString) {
- clearTimeout(searchTimerId);
- searchTimerId = setTimeout("search2('" + searchString + "')", 150);
- }
-
- function search2(searchString) {
- var content = document.getElementById('searchresults');
- content.innerHTML = "";
- if (searchString.length > 1){
- content.style.display = "block";
- content.innerHTML = "<h3>Søgeresultater</h3>";
- var objRegex = new RegExp("^" + searchString + "| *?" + searchString + "| " + searchString ,"i");
- var foundMatch = false;
-
- for(var i = 0; i < tmpMarker.length; i++){
- if(tmpMarker[i].navn_engelsk.match(objRegex) != null)
- {
- content.innerHTML += "<p><a href='javascript:myclick(" + i + ")' onmouseover='mymouseover(" + i + ")' onmouseout='mymouseout()'>" + tmpMarker[i].navn_engelsk + "</a></p>";
-
- foundMatch = true;
- }
- }
- if(!foundMatch){
- content.innerHTML += "<p>Intet fundet</p>";
-
- }
-
- }
- else{
- content.style.display = "none";
- content.innerHTML = "";
- }
- }
- function listUnits() {
- var units=[];
- $('#ku').find('a').each(function(){
- units.push([$(this).text(), $(this).parent().html()]);
- });
- units = units.sort();
- $('#ku').html('<ul><\/ul>');
- for(i=0;i<units.length;i++){
- $("#ku ul").append("<li>"+units[i][1]+"<\/li>");
- }
- var units=[];
- $('#life').find('a').each(function(){
- units.push([$(this).text(), $(this).parent().html()]);
- });
- units = units.sort();
- $('#life').html('<ul><\/ul>');
- for(i=0;i<units.length;i++){
- $("#life ul").append("<li>"+units[i][1]+"<\/li>");
- }
- var units=[];
- $('#farma').find('a').each(function(){
- units.push([$(this).text(), $(this).parent().html()]);
- });
- units = units.sort();
- $('#farma').html('<ul><\/ul>');
- for(i=0;i<units.length;i++){
- $("#farma ul").append("<li>"+units[i][1]+"<\/li>");
- }
- var units=[];
- $('#hum').find('a').each(function(){
- units.push([$(this).text(), $(this).parent().html()]);
- });
- units = units.sort();
- $('#hum').html('<ul><\/ul>');
- for(i=0;i<units.length;i++){
- $("#hum ul").append("<li>"+units[i][1]+"<\/li>");
- }
- var units=[];
- $('#jur').find('a').each(function(){
- units.push([$(this).text(), $(this).parent().html()]);
- });
- units = units.sort();
- $('#jur').html('<ul><\/ul>');
- for(i=0;i<units.length;i++){
- $("#jur ul").append("<li>"+units[i][1]+"<\/li>");
- }
- var units=[];
- $('#nat').find('a').each(function(){
- units.push([$(this).text(), $(this).parent().html()]);
- });
- units = units.sort();
- $('#nat').html('<ul><\/ul>');
- for(i=0;i<units.length;i++){
- $("#nat ul").append("<li>"+units[i][1]+"<\/li>");
- }
- var units=[];
- $('#samf').find('a').each(function(){
- units.push([$(this).text(), $(this).parent().html()]);
- });
- units = units.sort();
- $('#samf').html('<ul><\/ul>');
- for(i=0;i<units.length;i++){
- $("#samf ul").append("<li>"+units[i][1]+"<\/li>");
- }
- var units=[];
- $('#sund').find('a').each(function(){
- units.push([$(this).text(), $(this).parent().html()]);
- });
- units = units.sort();
- $('#sund').html('<ul><\/ul>');
- for(i=0;i<units.length;i++){
- $("#sund ul").append("<li>"+units[i][1]+"<\/li>");
- }
- var units=[];
- $('#teo').find('a').each(function(){
- units.push([$(this).text(), $(this).parent().html()]);
- });
- units = units.sort();
- $('#teo').html('<ul><\/ul>');
- for(i=0;i<units.length;i++){
- $("#teo ul").append("<li>"+units[i][1]+"<\/li>");
- }
- var units=[];
- $('#andre').find('a').each(function(){
- units.push([$(this).text(), $(this).parent().html()]);
- });
- units = units.sort();
- $('#andre').html('<ul><\/ul>');
- for(i=0;i<units.length;i++){
- $("#andre ul").append("<li>"+units[i][1]+"<\/li>");
- }
- $("#accordion").accordion({ autoHeight: false });
- }
-
-
-
- </script>