am63: "In Javascript all vars are global !"
javascript has an easy variable scope with global and local variable http://www.webdevelopersnotes.com/tutorials/javascript/global_local_variables_scope_javascript.php3 example 1. var *directionDisplay* = 10; 2. disp_a(); 3. function disp_a(){ 5. *var directionDisplay;* <--- *directionDisplay* is local 6. } 2010/8/6 am63 <[email protected]> > 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 <[email protected]> wrote: > > "directionsDisplay is not defined" > > > > declare directionsDisplay as global, it should fix the problem! > > > > 2010/8/6 [email protected] <[email protected]> > > > > > On Aug 5, 11:04 am, Lawrence <[email protected]> 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.. > .> > > > Line: 80 > > > > > -- Larry > > > > > > Here is the link: > > > > > >http://www.dart.org/presentations/directionsToRail.asp > > > > > > Thank you. > > > > Lawrence > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Google Maps JavaScript API v3" group. > > > To post to this group, send email to > > > [email protected]. > > > To unsubscribe from this group, send email to > > > [email protected]<google-maps-js-api-v3%[email protected]> > <google-maps-js-api-v3%[email protected]<google-maps-js-api-v3%[email protected]> > > > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/google-maps-js-api-v3?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Google Maps JavaScript API v3" group. > To post to this group, send email to > [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-maps-js-api-v3%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-maps-js-api-v3?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" 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-js-api-v3?hl=en.
