google.load(\"earth\", \"1\"); google.load(\"maps\", \"2.99\"); // For JS geocoder
var ge = null; var geocoder;
function init() { geocoder = new GClientGeocoder(); google.earth.createInstance(\"map3d\", initCB, failureCB); }
function initCB(object) { ge = object; ge.getWindow().setVisibility(true); ge.getNavigationControl().setVisibility(ge.VISIBILITY_SHOW);
GDownloadUrl(\"http://www.leehughes.co.uk/wp-content/leehughes.xml\", function(data, responseCode) { var xml;
if (window.ActiveXObject) { xml = GXml.parse(data); fParsed = xml.parsed; } else if (window.DOMParser) { var parser=new DOMParser(); xml=parser.parseFromString(data,\"text/xml\"); fParsed = true; }
var pages = xml.documentElement.getElementsByTagName(\"page\");
// Create Grundlefly style map for placemark var normal = ge.createIcon(''); normal.setHref('http://www.grundlefly.com/images/grundlefly_placemarker_gmaps.png'); var iconNormal = ge.createStyle(''); iconNormal.getIconStyle().setIcon(normal); var highlight = ge.createIcon(''); highlight.setHref('http://www.grundlefly.com/images/grundlefly_placemarker_gmaps.png'); var iconHighlight = ge.createStyle(''); iconHighlight.getIconStyle().setIcon(highlight); var styleMap = ge.createStyleMap(''); styleMap.setNormalStyle(iconNormal); styleMap.setHighlightStyle(iconHighlight);
// Create Standard style map for External Travel web page placemarks var normal2 = ge.createIcon(''); normal2.setHref('http://www.grundlefly.com/images/external_placemarker.png'); var iconNormal2 = ge.createStyle(''); iconNormal2.getIconStyle().setIcon(normal2); var highlight2 = ge.createIcon(''); highlight2.setHref('http://www.grundlefly.com/images/external_placemarker.png'); var iconHighlight2 = ge.createStyle(''); iconHighlight2.getIconStyle().setIcon(highlight2); var styleMap2 = ge.createStyleMap(''); styleMap2.setNormalStyle(iconNormal2); styleMap2.setHighlightStyle(iconHighlight2);
for (var i = 0; i < pages.length; i++) { var ptag = pages[i].getAttribute(\"pageTag\"); var externalPage = pages[i].getAttribute(\"externalPage\"); var pageLink = pages[i].getAttribute(\"alternatePageLink\");
// decide which placemark icon to use if (externalPage == \"yes\") { placemark.setStyleSelector(styleMap2); } else { placemark.setStyleSelector(styleMap); }
// Create placemarker title var title = pages[i].getAttribute(\"title\"); placemark.setName(title);
// Extract some stuff from the XML file - I wish I didn't have to extract 3 x times // but not sure of any other way to do it / reference this info in statements below // Logic would suggest that I should only have to do this once var id = pages[i].getAttribute(\"id\"); var title = pages[i].getAttribute(\"title\"); var summary = pages[i].getAttribute(\"summary\");
// Create point var lat = pages[i].getAttribute(\"lat\"); var lng = pages[i].getAttribute(\"lng\"); var point = ge.createPoint(''); point.setLatitude(parseFloat(lat)); point.setLongitude(parseFloat(lng)); placemark.setGeometry(point); createPlacemark(placemark, id, title, summary, pageLink, externalPage); } } }); }
function createPlacemark(placemark, id, title, summary, pageLink, externalPage) { var currentPlacemark = placemark; var keyword = id; var titlename = title; var short_summary = summary; var alternateURL = pageLink; var externalLink = externalPage;
// Set a timeout function to close the InfoBalloon after 6 seconds // window.setTimeout(function() { ge.setBalloon(null); }, 6000);
});
return currentPlacemark; }
function failureCB(object) { alert('load failed'); }
function submitLocation() { var address = document.getElementById('address').value; geocoder.getLatLng( address, function(point) { if (point && ge != null) { var la = ge.createLookAt(''); // 40000 number being the zoom-to view altitude for those interested la.set(point.y, point.x, 100, ge.ALTITUDE_RELATIVE_TO_GROUND, 0, 0, 40000); ge.getView().setAbstractView(la); } } ); }
Am guessing this will slow the page load time alot ?
Also this contains something like 70 validation errors..
Am thinking of getting rid of this as I don't fancy attempting to fix the errors and to view the map you need to install a google plugin which I doubt strangers would do just to view it.
any other things that could be slowing down my page?
1) As you've noticed, it totally slows the website down, and
2) Some people (probably the majority), won't have the Google Earth plugin (like me, for example). So I waited and waited only to have something tell me that I couldn't view it.
If you want to have it, put it on a special page that people can go to, certainly not the index.
Due to the way the code is done.. I have to put it in the header which basically means that every page that is viewed would have to scan through this code..
Just wondering how much this would slow down the page..
lol.. dont blame yourself.. even I never thought of it that we could put the required javascripts in the respected templates rather than including them in the header! Thanks a ton TheDoc! ;)
After going round a few forums asking for reviews of my site, one problem keeps coming up. The load time of my site is too slow..
How can I speed this up?
I just recently added a 3D map to my site which contains the following in the header
Am guessing this will slow the page load time alot ?
Also this contains something like 70 validation errors..
Am thinking of getting rid of this as I don't fancy attempting to fix the errors and to view the map you need to install a google plugin which I doubt strangers would do just to view it.
any other things that could be slowing down my page?
Thanks
http://www.leehughes.co.uk
http://www.leehughes.co.uk/3d-route/
thanks
1) As you've noticed, it totally slows the website down, and
2) Some people (probably the majority), won't have the Google Earth plugin (like me, for example). So I waited and waited only to have something tell me that I couldn't view it.
If you want to have it, put it on a special page that people can go to, certainly not the index.
Due to the way the code is done.. I have to put it in the header which basically means that every page that is viewed would have to scan through this code..
Just wondering how much this would slow down the page..
Looks like I will have to loose it :(
Just create a new template specific for the page that will have the map on it. Only put the JS in that template.