www.gusucode.com > 200套html5精品模板1_50 > 200套html5精品模板1_50/032/js/googleMap.js
$(window).load(function(){ var mapUrl = "../../https@maps.google.com/maps@f=q&source=s_q&hl=en&geocode=&q=Brooklyn,+New+York,+NY,+United+States&aq=0&sll=37.0625,-95.677068&sspn=610C8A8B34AD", onLoadWebSite = false, googleMapHolder = $(".google_map"), backgroundColor = googleMapHolder.css("backgroundColor"), backgroundURL = googleMapHolder.css("backgroundImage"), backgroundRepeat = googleMapHolder.css("backgroundRepeat"), mapWidth=googleMapHolder.css("width"), mapHeight=googleMapHolder.css("height"), borderTopLeftRadius = googleMapHolder.css("borderTopLeftRadius"), borderTopRightRadius = googleMapHolder.css("borderTopLeftRadius"), borderBottomLeftRadius = googleMapHolder.css("borderTopLeftRadius"), borderBottomRightRadius = googleMapHolder.css("borderTopLeftRadius"), addMap=false, idPage, intervalCall; if(backgroundColor == "rgba(0, 0, 0, 0)"){ backgroundColor= "#ffffff"; } verificationPageHandler(); if(onLoadWebSite == false){ $(window).bind("hashchange", verificationPageHandler); } function verificationPageHandler(){ if(onLoadWebSite == false){ idPage = "#"+window.location.hash.substring(3, window.location.hash.length); if(idPage != "#"){ if(googleMapHolder.parents(idPage).length != 0){ addGoogleMapHandler(); } } }else{ addGoogleMapHandler(); } } function addGoogleMapHandler(){ if(!addMap){ addMap = true; $(window).unbind("hashchange", verificationPageHandler); googleMapHolder.css({"overflow":"hidden"}); googleMapHolder.append("<div id='loaderPart' style='position:absolute; z-index:1; width:"+mapWidth+"; height:"+mapHeight+"; background-color:"+backgroundColor+"; background-image:"+ backgroundURL + ";background-repeat:"+backgroundRepeat+ "; background-position: center center; border-top-left-radius:"+borderTopLeftRadius+"; border-top-right-radius:"+borderTopRightRadius+"; border-bottom-right-radius:"+borderBottomLeftRadius+"; border-bottom-left-radius:"+borderBottomRightRadius+";'></div>"); intervalCall = setInterval(addIframe, 200) } function addIframe(){ if($(idPage).css("display")!="none"){ clearInterval(intervalCall); googleMapHolder.append("<iframe width='"+mapWidth+"' height='"+mapHeight+"' frameborder='0' src='"+mapUrl+"' style='position:absolute; z-index:0; border-top-left-radius:"+borderTopLeftRadius+"; border-top-right-radius:"+borderTopRightRadius+"; border-bottom-right-radius:"+borderBottomLeftRadius+"; border-bottom-left-radius:"+borderBottomRightRadius+";'></iframe>"); googleMapHolder.find("iframe").load(googleMapLoadCompleteHandler); } } } function googleMapLoadCompleteHandler(){ var loaderPart = googleMapHolder.find("#loaderPart"); loaderPart.delay(100).fadeOut(500, function(){loaderPart.css({"display":"none"});}); } })