Hi there,

I'm re-writing parts of my jMaps plugin and I've hit a strange error
with GDirections.

First of all, here is my code:

Mapifies.SearchDirections = function( element, options, callback) {
        function defaults() {
                return {
                        // From address
                        'fromAddress': '',
                        // To address
                        'toAddress': '',
                        // Optional panel to show text directions
                        'panel': "",
                        //The locale to use for the directions result.
                        'locale': 'en_GB',
                        //The mode of travel, such as driving (default) or 
walking
                        'travelMode': 'driving'
                };
        };
        var thisMap = Mapifies.MapObjects.Get(element);
        options = jQuery.extend(defaults(), options);

        var queryOptions = {
                'locale': options.locale,
                'travelMode': options.travelMode
        };

        var panel = $(options.panel).get(0);
        var directions = new GDirections(thisMap, panel);
        directions.load('from: ' +options.fromAddress + ' to: ' +
options.toAddress, queryOptions);
        if (typeof callback == 'function') return callback(directions,
options);
        return;
};

var SearchDirectionsErrorHandler = function(errorCode){

        switch (errorCode) {
                case G_GEO_UNKNOWN_ADDRESS:
                        return "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: " +
errorCode;
                        break;
                case G_GEO_SERVER_ERROR:
                        return "A geocoding or directions request could not be 
successfully
processed, yet the exact reason for the failure is not known.\n Error
code: " + errorCode;
                        break;
                case G_GEO_MISSING_QUERY:
                        return "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: " + errorCode;
                        break;
                case G_GEO_BAD_KEY:
                        return "The given key is either invalid or does not 
match the
domain for which it was given. \n Error code: " + errorCode;
                        break;
                case G_GEO_BAD_REQUEST:
                        return "A directions request could not be successfully 
parsed.\n
Error code: " + errorCode;
                        break;
                default:
                        return "An unknown error occurred.";
                break;
        };
};

Then, when using the function I do this:

$('#map3').jmap('init').jmap('SearchDirections',
{'fromAddress':'Edinburgh', 'toAddress':'London',
'panel':'#directions'}, function(directions){
                                var error =
SearchDirectionsErrorHandler(directions.getStatus().code);
                                console.log(error);
                        });

The problem is that, with either a valid addresses or invalid address,
the getStatus().code ALWAYS seems to return a 500 error.

Anyone any ideas why?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to