TweakPC

Zurück   Computer Hardware Forum - TweakPC > Games und Software > Programmiersprachen
Registrieren Hilfe Community Downloads

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 30.12.2006, 22:52   #1 (permalink)
Overclocker
 
Benutzerbild von LeoHart
 

Registriert seit: 18.04.2004
Beiträge: 292

LeoHart befindet sich auf einem aufstrebenden Ast

Standard Proplem mit Javascript (map24 API)

Hallo,
hab ein "kleines" Problem mit der Einbindung von map24 auf meiner HP. Zwar gibt es auf der map24 HP eine sehr gute Tutorial Seite aber die hilft mir hier nicht weiter. Wollte folgende Funtkionen einbinden einmal das man zwischen statisch und interaktiver Karte wählen kann, was auch immer funktioniert , dann soll die Route berechnet werden [Routing] und ein beliebiger Standort [Geocoding Basics]

Hab das Problem das sich die Funktion Routing und Geocoding Basics irgendwie stören. Bei diesem Code unten funktioniert Geocoding Basics aber bei der Funktion Routing wird keine Route berechnet sondern nur der Startort. Sehe aber nicht wo da der Fehler sein soll.

Code:
<html>

  <head>
    <script language="javascript"  type="text/javascript" src="http://api.map24.com/ajax/1.2/?init=default"></script>
    <script language="javascript" type="text/javascript" >
      var map = null;
 
      function goMap24() {
      
      map = Map24.Webservices.getMap24Application({
        AppKey:"00000000000000000000000000000000",
        MapArea:document.getElementById("maparea"),
          Maptype: "JAVA",
        MapWidth: 550,
        MapHeight: 550
      });
      }
 
      function setMGI(){
        map.setMaptype( "MGI" );
      }
      
      function setJava(){
        map.setMaptype( "JAVA" );
      }

       function calculateRouteAddr( start, destination ){
        if( Map24.isNull( start ) ) return;
        if( Map24.isNull( destination ) ) return;
 
        geocodeStartAndDestination( start, destination );
        return;
      }
      
      function geocodeStartAndDestination( start, destination ){
        //1. Geocode the start address
        geocode( start, onGeocodeStart )
 
        //2. When start address has been geocoded, then geocode destination address
        function onGeocodeStart( geoRes ){
          startGeocoded = geoRes.firstResult;
          geocode( destination, onGeocodeDest )
        }
        //3. When both start and dest address have been geocoded, then start route calculation
        function onGeocodeDest( geoRes ){
          destinationGeocoded = geoRes.firstResult;
          calculateRouteCoord( startGeocoded, destinationGeocoded );
        }
      }
      
      //Calculate a route between two addresses
      function calculateRouteCoord( startGeocoded, destinationGeocoded ){
        if( Map24.isNull( startGeocoded ) ) return;
        if( Map24.isNull( destinationGeocoded ) ) return;
      
        var routeRequest = new Map24.Webservices.Request.CalculateRoute( map );
        routeRequest.Start = new Map24.Webservices.Request.CalculateRoute.CoordinateAndAddress();
        routeRequest.Start.Coordinate = new Map24.Coordinate( startGeocoded.Coordinate.Longitude,
                                                              startGeocoded.Coordinate.Latitude );
        routeRequest.Destination = new Map24.Webservices.Request.CalculateRoute.CoordinateAndAddress();
        routeRequest.Destination.Coordinate = new Map24.Coordinate( destinationGeocoded.Coordinate.Longitude,
                                                                    destinationGeocoded.Coordinate.Latitude );
        map.Webservices.sendRequest( routeRequest );
      
       //This listener is called when the route calculation has finished
        map.onCalculateRoute = function( event ){
          var mrcContainer = new Map24.Webservices.Request.MapletRemoteControl( map );
          mrcContainer.push( 
            new Map24.Webservices.MRC.DeclareMap24RouteObject({
              MapObjectID: "actualRoute",
              Map24RouteID: event.Info.RouteID,
              Color: new Map24.Color( 255, 0, 0, 180 )
            }) 
          );
          //Center the map view on the route visualization
          mrcContainer.push( genSetMapView( 0, 70, null, null, "actualRoute" ) );
          
          //Enable the visibility of the route 
          mrcContainer.push( genControlMapObject( "ENABLE", "actualRoute" ) );
          
          map.Webservices.sendRequest( mrcContainer );
        }
      }
      
      //Geocoding
      function geocode( address, onGeoFunc ){
        map.Webservices.sendRequest(
          new Map24.Webservices.Request.MapSearchFree(map, {
            SearchText: address,
            MaxNoOfAlternatives: 50
          })
        );
      
        map.onMapSearchFree = function( event ){
          var geoRes = new Object();
          geoRes.Alternatives = event.Alternatives;
          geoRes.firstResult = geoRes.Alternatives[0];
 
          onGeoFunc( geoRes );
        }
      }    
      
      //Factory functions
      function genSetMapView( ClippingWidth, ClippingPercent, lon, lat, objID ){
        //Hashtable Clip { MinimumWidth: ClippingWidth, ViewPercentage: ClippingPercent } is created
        var Clip = new Array();
        if( !Map24.isNull( ClippingWidth ) ) 
          Clip['MinimumWidth'] = ClippingWidth;
        if( !Map24.isNull( ClippingPercent ) )
          Clip['ViewPercentage'] = ClippingPercent;
        
        if( !Map24.isNull( lon ) && !Map24.isNull( lat ) )
        {
          var SetMapView = new Map24.Webservices.MRC.SetMapView({
            ClippingWidth: new Map24.Webservices.ClippingWidth( Clip ),
            Coordinates: new Map24.Coordinate( lon, lat )
          });
        } 
        else if( !Map24.isNull( objID ) )
        {
          var SetMapView = new Map24.Webservices.MRC.SetMapView({
            ClippingWidth: new Map24.Webservices.ClippingWidth( Clip ),
            MapObjectIDs: objID 
          });
        }    
        return SetMapView;    
      }        
      
      function genControlMapObject( Control, objID ){
        var ControlObject = new Map24.Webservices.MRC.ControlMapObject({
          Control: Control,
          MapObjectIDs: objID
        });
        return ControlObject;
      }   

      function geocode( addressString ){
        map.Webservices.sendRequest(        
          new Map24.Webservices.Request.MapSearchFree(map, {
            SearchText: addressString,
            MaxNoOfAlternatives: 50
          })
        );
        
        map.onMapSearchFree = function( event ){
          var mrcContainer = new Map24.Webservices.Request.MapletRemoteControl( map );
          var firstResult = event.Alternatives[0];
          var lon = firstResult.Coordinate.Longitude;
          var lat = firstResult.Coordinate.Latitude;
          
          mrcContainer.push(
            new Map24.Webservices.MRC.SetMapView({
              Coordinates: new Map24.Coordinate( lon, lat ),
              ClippingWidth: new Map24.Webservices.ClippingWidth(
                { MinimumWidth: 5000 }              
              )
            })
          );
          map.Webservices.sendRequest( mrcContainer );
        }
      }
    </script>

  </head>
HTML-Code:
<b>Ort</b>
                    <input id="req" type="text" style="margin-top:8px" size=20 maxlength=50 value='000 Ort'>
                    
                    <input type="image" src='http://img.map24.com/map24/portal/fr-fr/dyna/btn_next0.png' style="margin-top:5px" 
           onclick="return geocode(document.getElementById('req').value)">
                    

                    <b>Route</b>
                    Start:
                    <input type='text' name='start_address' id='start_address' size='20' value=''>
                    Ziel:
                    <input type='text' name='dest_address' id='dest_address' size='20' value='000 Ort'>
                    <a href='javascript:calculateRouteAddr(document.getElementById("start_address").value, 
             document.getElementById("dest_address").value);'>
                       <img src='http://img.map24.com/map24/portal/fr-fr/dyna/btn_next0.png' border=0>
Dachte auch schon daran das vieleicht etwas mit den Variabeln im html-Teil nicht stimmt aber sehe hier auch nichts.

Sollte noch anmerken das ich mich mit Javascript nicht auskenne, habe lediglich die Funktionen einander gesetzt und versucht darauf zu achten das die geschweiften Klammen stimmen.

Hoffe ihr kennt euch mit map24 etwas aus ^^

:Edit:
was ich noch vergessen zu erwähnen habe ist das, dass Applet nur unter FiferFox funktioniert, der IE zeigt gar nichts an außer einen Platzhalter mit der größe des Applets.
LeoHart ist offline   Mit Zitat antworten
Antwort

Stichworte
api, javascript, map24, proplem


Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
 

Forumregeln
Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist aus.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are an


Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
Firefox 16 Javascript Anwendung? PLACEBO76 Windows & Programme 6 22.02.2013 16:12
Javascript aus Iframe heraus daPR Programmiersprachen 0 17.06.2006 14:26
Mailadresse verstecken mit Javascript UnoOC Programmiersprachen 2 07.03.2006 07:54
Javascript Frage Freddy K. Programmiersprachen 4 28.04.2003 15:14
Javascript Probleme, wie zentrieren ? Programmiersprachen 1 01.12.2002 00:17


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:13 Uhr.






Powered by vBulletin® Version 3.8.10 (Deutsch)
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
SEO by vBSEO 3.5.2 ©2010, Crawlability, Inc.
Impressum, Datenschutz Copyright © 1999-2015 TweakPC, Alle Rechte vorbehalten, all rights reserved