Google Maps don't fully load

前端 未结 7 1970
無奈伤痛
無奈伤痛 2020-12-29 08:32

I have a somewhat strange problem. I have two maps on my site, a big one and a small one. I want to use the big one to show a route to a certain address. I\'m now trying to

7条回答
  •  时光取名叫无心
    2020-12-29 09:16

    I fixed it!

    I made an own function for the largemap and placed it in the callback when the elements are opened

    
    function largeMap(){
     var largeLatlng = new google.maps.LatLng(51.92475, 4.38206);
     var largeOptions = {zoom: 10, center: largeLatlng,mapTypeId: google.maps.MapTypeId.ROADMAP};
     var largeMap = new google.maps.Map(document.getElementById("largeMap"), largeOptions);
     var largeMarker = new google.maps.Marker({position: largeLatlng, map:largeMap, title:"Cherrytrees"});
     largeMarker.setMap(largeMap);
    }
    [..]
     $("#showRoute").click(function(e){
      e.preventDefault();
      $("#shadow").add($("#shadowContent"),$("#closebar"),$("#content")).fadeIn(500);
      $("#shadowContent").show().css({'width':'750px','top':'25px','left':'50%','margin-left':'-400px'});
      $("#closeBarLink").click(function(l){
       l.preventDefault();
       $("#shadow").add($("#shadowContent"),$("#closebar"),$("#content")).fadeOut(500);
      });
      largeMap();
     });
    

    Thanks anyway!!

提交回复
热议问题