views:

633

answers:

2

Best way to describe this problem is with a link. Please visit this page: Ruby International | APOAds.com

In FireFox, everything works fine. In IE it load the directions but does not center on them. Perhaps it's only my PC, does it work on yours under IE?

Here's the javascript doing the brunt of the work:

$(function() {
    // panorama of business
    var biz = new GLatLng(35.796532,139.406645);
    panoramaOptions = { latlng:biz };
    myPano = new GStreetviewPanorama($("div#geoMap").get(0), panoramaOptions);

    // get map for directions
    var dirMap = new GMap2($("div#dirMap").get(0));
    dirMap.setCenter(new GLatLng(35.740066,139.347582), 12);
    dirMap.setUIToDefault();

    // load directions
    directions = new GDirections(dirMap, $("div#dirMapText").get(0));
    directions.load("from: [email protected],139.347582 to: Ruby [email protected],139.406645");

    $("#tabs").tabs({ cookie: { expires: 30 } });
});

Any assistance is greatly appreciated. (人)

A: 

strange question, but have you tried calling setCenter last?

Jonathan Fingland
I haven't, lemme give that a go.I did notice that the centering problem is only on first load. If I hit refresh, it centers fine. o.0?
Chad
BTW, I set it right after the Gmap2 constructor because of this (from the Google Maps API docs):Note: a Map needs to be centered before it can be used. You should immediately call GMap2.setCenter() to initialize a map created with this constructor.
Chad
I notice you're using jquery... is this being done inside of a $(document).ready()? It sounds like the second time, it's been cached, and the first time it wasn't finished loading yet.
Jonathan Fingland
it is in a $(function() { ...gMapsCode... }); yes. but the comment has me thinking... thx. Do things load alright for you?
Chad
but is it: $(document).ready($(function() { ...gMapsCode... });)? It works fine in FF3 and does not work the first time in IE8 (works afterwards)
Jonathan Fingland
good point... theoretically they should be the same... I'll check it
Chad
Nope... didn't resolve it. hmm...
Chad
+3  A: 

Update: You are calling your directions function before you initialize the tabs - but by the time that the directions request gets back to the browser, the tabs have already been initialized and the request is getting fouled up in IE. You can fix it by using the second suggestion here - Set up a listener to call your directions function when the tab is clicked on.

$('#tabs').bind('tabsshow', function(event, ui) {
    if (ui.panel.id == "tabs-5") {
     directions = new GDirections(dirMap, $("div#dirMapText").get(0));
     directions.load("from: [email protected],139.347582 to: Ruby [email protected],139.406645");
    }
});
Chris B
I resolved that issue by not calling the .tabs() code until after the Google maps have loaded. But just in case I tried applying the fix you mention, the problem remains.
Chad
so problem resolved? You can post your solution (and accept it) so that others searching for this problem can find a resolution
Jonathan Fingland
Different issue... but Chris updated his answer. Gonna implement that real quick and see if it works. Thanks Chris!
Chad
Chris... that works! You're a life-saver!
Chad
No problem :) Stupid IE
Chris B