Firefox issue

125 views
Skip to first unread message

Lawrence

unread,
Aug 5, 2010, 2:04:34 PM8/5/10
to Google Maps JavaScript API v3
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?

Here is the link:

http://www.dart.org/presentations/directionsToRail.asp


Thank you.
Lawrence

geoco...@gmail.com

unread,
Aug 5, 2010, 6:02:17 PM8/5/10
to Google Maps JavaScript API v3
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=pushGeoData&geoData=(32.750341,%20-97.067835)&address=616%206%20Flags%20Dr,%20Arlington,%20TX%2076011,%20USA&mode=DRIVING&parking=YES&timeOfDay=Early%20Morning&monthSelected=9&dateSelected=24
Line: 80

-- Larry

Federico Ulfo

unread,
Aug 5, 2010, 6:17:44 PM8/5/10
to google-map...@googlegroups.com
"directionsDisplay is not defined"

declare directionsDisplay as global, it should fix the problem!


--
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 google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.


am63

unread,
Aug 6, 2010, 2:38:49 AM8/6/10
to Google Maps JavaScript API v3
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...>
> > 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
> > google-map...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2Bunsu...@googlegroups.com>
> > .

Federico Ulfo

unread,
Aug 6, 2010, 4:51:37 AM8/6/10
to google-map...@googlegroups.com
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 <assistancem...@gmail.com>
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.

Lawrence

unread,
Aug 6, 2010, 3:50:01 PM8/6/10
to Google Maps JavaScript API v3
Thanks for the assistance everybody. The issue was not with the global
var. Since that was named outside of a function it was global. What I
had to do was call the initialize function before my map call. I
originally had the initialize function called in my html body onload.
Apparently in Firefox, the Javascript is run before the HTML, as
opposed to IE which runs all of your HTML first. I was unaware of
this. The page works great now!

Thanks to Google for a great API tool. I especially appreciate the
bicycle path, and look forward to when the transit data is available
through the API.


Thanks again to all!
Lawrence

On Aug 6, 3:51 am, Federico Ulfo <rainelemen...@gmail.com> wrote:
> am63: "In Javascript all vars are global !"
>
> javascript has an easy variable scope with global and local variablehttp://www.webdevelopersnotes.com/tutorials/javascript/global_local_v...
>
> example
>
> 1. var *directionDisplay* = 10;
> 2. disp_a();
> 3. function disp_a(){
> 5.   *var directionDisplay;* <--- *directionDisplay* is local
> 6. }
>
> 2010/8/6 am63 <assistancemultimedi...@gmail.com>
> > <google-maps-js-api-v3%2Bunsu...@googlegroups.com<google-maps-js-api-v3%252Buns...@googlegroups.com>
Reply all
Reply to author
Forward
0 new messages