In Javascript all vars are global !
However, your directionsDisplay var is defined just after script
loading (script tag) ; it should be set in the Initialize function,
which is called when the page (including all its scripts) has finished
loading.
If you directly call API functions just after the <script type="text/
javascript" src="
http://maps.google.com/maps/api/js?sensor=false"></
script>, the Maps API generally has not finished loading when
executing the following code.
That's why we are using the Body onLoad event, to differ code
execution until the page/scripts are all loaded.
On 6 août, 00:17, Federico Ulfo <
rainelemen...@gmail.com> wrote:
> "directionsDisplay is not defined"
>
> declare directionsDisplay as global, it should fix the problem!
>
> 2010/8/6
geocode...@gmail.com <
geocode...@gmail.com>
>
> > On Aug 5, 11:04 am, Lawrence <
lawrencesutton...@gmail.com> wrote:
> > > I am using the Google Map API to display driving directions based on
> > > an address entered into a form that I have to do some calculations on.
> > > To submit the form I call the JavaScript function codeAddress and then
> > > use window.location to redirect to my map display page and have
> > > JavaScript and VBScript mixed together to render the driving
> > > directions with some mass transit schedule information.
>
> > > This all works fine in IE. However in Firefox the map initializes fine
> > > but will only occasionally render the driving path and text
> > > directions.
>
> > > Any suggestions?
>
> > As firefox has much more useful debugging tools than IE, I have to
> > ask:
> > Did you look at the Error Console (Tools:Error Console or Ctrl-Shift-
> > J)?
>
> > There seem to be some obvious ones, like:
> > Error: directionsDisplay is not defined
> > Source File:
>
> >
http://www.dart.org/presentations/directionsToRail.asp?switch=pushGeo...<
http://www.dart.org/presentations/directionsToRail.asp?switch=pushGeo...>
> >
google-maps-js-a...@googlegroups.com<
google-maps-js-api-v3%2Bunsu...@googlegroups.com>
> > .