lopes_andre Posted December 26, 2009 Share Posted December 26, 2009 Hi, I have done some JavaScript code for Google Maps API, and the code works, but I need to use the JavaScript in a external file at the same time I need to send a parameter... Let me show some code... Here is the function that I need to send the parameter: // parameter that I need to send var direction_par; function initialize(direction_par) { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map_canvas")); map.setUIToDefault(); // adicionar os controlosao mapa ZOOM, etc. // Create new geocoding object geocoder = new GClientGeocoder(); // Retrieve location information, pass it to addToMap() geocoder.getLocations(direction_par, addToMap); // Criar o objecto que mostra as direcções gdir = new GDirections(map, document.getElementById ("directions")); GEvent.addListener(gdir, "load", onGDirectionsLoad); GEvent.addListener(gdir, "error", handleErrors); } } This is where I call the script: script type="text/javascript" src="http://localhost/acomp_www/javascript/gm_detalhe.js?direction_par=Rue de la Mad, paris, france"> </script> And here is where the function "initialize" is called: <body onload="initialize(direction_par)" onunload="GUnload()"> What I'am doing wrong? There is a special way to pass parameters like this one "Rue de la Mad, paris, france", whit spaces? If you can help me out, please reply. Best Regards, Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 26, 2009 Share Posted December 26, 2009 I think your code should be <body onload="initialize('Rue de la Mad, paris, france')" onunload="GUnload()"> Quote Link to comment Share on other sites More sharing options...
lopes_andre Posted December 26, 2009 Author Share Posted December 26, 2009 Great! It is working now! Best Regards, Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.