Google Maps api

Aurora-One

Grünschnabel
hi leutz,
habe en kleines Problem, denke ich mal.

Ich habe mir ein Script gebaut mit Google Api, dass ich eine Route berechnet von dem Ort wo der User eine Eingenabe macht zb Wohnort bzw an dem Ort wo er gerade ist (Dynamisch) zu einem Festort (Statisch).

Alles geht bei mir auf dem rechner, nur in Joomla (CMS) gehts dann nicht mehr dynamisch!
Hier der code:
HTML:
<html>
<head>
  <title></title>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAKySvAi9EQLV7UCG8fdTsvRQUuxv3mYViEV0ivgEwULrjMyyttRRqZyihq5xCpQb6BVBk4RbSgM390g" type="text/javascript">
</script>
<script type="text/javascript">
    function setDirections(fromAddress) {
            gdir.load("from: " + fromAddress + " to: Ort und Straße",
                    {"locale": "de_DE"});
    }

    function handleErrors() {
            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)
                    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_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
            //     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_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 alert("An unknown error occurred.");

    }
    function onGDirectionsLoad(){
          // Use this function to access information about the latest load()
          // results.

          // e.g.
	  // document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
	  // and yada yada yada...
	}
    var map;
    var gdir;
    var geocoder = null;
    var addressMarker;
    function initialize() {
            var point = new GLatLng (48.61951997794109, 9.538793563842773)

            if (GBrowserIsCompatible()) {
                    var map = new GMap2(document.getElementById("map"));
                    map.setMapType (G_HYBRID_MAP);
                    map.setCenter(point, 17);
                    gdir = new GDirections(map, document.getElementById("directions"));
                    GEvent.addListener(gdir, "load", onGDirectionsLoad);
                    GEvent.addListener(gdir, "error", handleErrors);

                    var myIcon = new GIcon();
                    myIcon.image = '/externe_seite/markers/image.png';
                    myIcon.shadow = '/externe_seite/markers/shadow.png';
                    myIcon.iconSize = new GSize(80, 36);
                    myIcon.shadowSize = new GSize(98, 36);
                    myIcon.iconAnchor = new GPoint(0, 36);
                    myIcon.infoWindowAnchor = new GPoint(40, 0);
                    myIcon.printImage = '/externe_seite/markers/printImage.gif';
                    myIcon.mozPrintImage = '/externe_seite/markers/mozPrintImage.gif';
                    myIcon.printShadow = '/externe_seite/markers/printShadow.gif';
                    myIcon.transparent = '/externe_seite/markers/transparent.png';
                    myIcon.imageMap =[30, 0, 44, 1, 37, 2, 40, 3, 76, 4, 78, 5, 78, 6, 79, 7, 79, 8, 79, 9, 79, 10, 79, 11, 79, 12, 79, 13, 79, 14, 79, 15, 79, 16, 79, 17, 79, 18, 79, 19, 79, 20, 79, 21, 79, 22, 79, 23, 79, 24, 79, 25, 79, 26, 79, 27, 79, 28, 79, 29, 79, 30, 78, 31, 77, 32, 75, 33, 34, 34, 29, 35, 15, 35, 8, 34, 1, 33, 0, 32, 0, 31, 0, 30, 0, 29, 0, 28, 0, 27, 0, 26, 0, 25, 0, 24, 0, 23, 0, 22, 0, 21, 0, 20, 0, 19, 0, 18, 0, 17, 0, 16, 0, 15, 0, 14, 0, 13, 0, 12, 0, 11, 0, 10, 0, 9, 0, 8, 1, 7, 1, 6, 1, 5, 1, 4, 5, 3, 8, 2, 13, 1, 20, 0];

                    var marker = new GMarker(point, myIcon);
                    map.addOverlay(marker);
                    GEvent.addListener(marker, "click", function()
                            {
                                    marker.openInfoWindowHtml("<p style='color: #000000'><strong>Name<\/strong> <br/> Straße <br /> Ort<\/p>");
                            }
                    );
                    setDirections("Berlin", "München", "de_DE");
                    map.setUIToDefault ();
            }
    }

</script>
</head>

<body onload="initialize()" onunload="GUnload()">
  <form action="#" onsubmit="setDirections(this.from.value); return false">
    <table>
      <tr>
        <th align="right">Von: </th>

        <td><input type="text" size="25" id="fromAddress" name="from" value="z. B. Berlin"></td>

        <th align="right"> </th>

        <td align="right"> </td>
      </tr>

      <tr>
        <th> </th>

        <td colspan="3"><input name="submit" type="submit" value="Route Berechnen!"></td>
      </tr>
    </table>
  </form>

  <div id="directions" style="width: 275px; float:left"></div>

  <div id="map" style="width: 600px; height: 400px; float: right"></div>
</body>
</html>

danke für euere hilfe im Vorraus

Mfg
Aurora-One
 
Moin Aurora,

was genau geht denn nicht?

dein Code geht bei mir auch nicht, weil Google wohl mit der Zieladresse nichts anfangen kann:
Code:
function setDirections(fromAddress) {
            gdir.load("from: " + fromAddress + " to: Ort und Straße",
                    {"locale": "de_DE"});
    }
...Ort und Straße ist doch etwas zu allgemein gehalten, selbst für Google :)
 

Neue Beiträge

Zurück