最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to insert google map in popup or lightbox? - Stack Overflow

programmeradmin4浏览0评论

I want to ask! I'm designing an application, but there is a problem in inserting a google map in a popup or lightbox which display the map can not meet the "div id="wrap_peta"" like in the picture. The problem is not caused by the failure loading map

I asked for help from all of what's wrong in my script thanks fo everyone

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ".dtd">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/lightbox.css"/>
<link rel="stylesheet" type="text/css" href="css/index.css"/>
<script src=".exp&sensor=false"></script>
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
<script type="text/javascript">
    function load_peta() 
    {
        var semarang = new google.maps.LatLng(-7.201470266411334, 110.08918792956547);
        var petaoption = {
        zoom: 9,
        center: semarang,
        mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        peta = new google.maps.Map(document.getElementById("peta"),petaoption);
        google.maps.event.addListener(peta,'click',function(event){
        kasihtanda(event.latLng);
        });

        load_list_terminal('awal');

    }
    google.maps.event.addDomListener(window, 'load', load_peta);
</script>

<title>Untitled Document</title>
</head>

<body>
    <!--Bagian Bar Navigasi Atas termasuk search -->
    <div id="bar_atas">
        <div style="margin:auto; margin-top:5px; padding:5px 5px 5px 5px; height:50px; width:90%;">
        <h1>GIS Hubkominfo</h1>
        </div>
    </div>
    <div>
    <p><a onclick="show_lightbox()" href="javascript:void()">input terminal</a></p>
    </div>

    <div id="background" onclick="hide_lightbox()" class="bgdasar"></div>
    <div id="popup" class="wraplightbox" style="margin:auto">
        <p onclick="hide_lightbox()" style="cursor:pointer">tutup</p>
        <div id="peta" style="height:300px; margin-bottom:10px; border:solid #999 2px;"></div>
    </div>
</body>
</html>

I want to ask! I'm designing an application, but there is a problem in inserting a google map in a popup or lightbox which display the map can not meet the "div id="wrap_peta"" like in the picture. The problem is not caused by the failure loading map

I asked for help from all of what's wrong in my script thanks fo everyone

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/lightbox.css"/>
<link rel="stylesheet" type="text/css" href="css/index.css"/>
<script src="https://maps.googleapis./maps/api/js?v=3.exp&sensor=false"></script>
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
<script type="text/javascript">
    function load_peta() 
    {
        var semarang = new google.maps.LatLng(-7.201470266411334, 110.08918792956547);
        var petaoption = {
        zoom: 9,
        center: semarang,
        mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        peta = new google.maps.Map(document.getElementById("peta"),petaoption);
        google.maps.event.addListener(peta,'click',function(event){
        kasihtanda(event.latLng);
        });

        load_list_terminal('awal');

    }
    google.maps.event.addDomListener(window, 'load', load_peta);
</script>

<title>Untitled Document</title>
</head>

<body>
    <!--Bagian Bar Navigasi Atas termasuk search -->
    <div id="bar_atas">
        <div style="margin:auto; margin-top:5px; padding:5px 5px 5px 5px; height:50px; width:90%;">
        <h1>GIS Hubkominfo</h1>
        </div>
    </div>
    <div>
    <p><a onclick="show_lightbox()" href="javascript:void()">input terminal</a></p>
    </div>

    <div id="background" onclick="hide_lightbox()" class="bgdasar"></div>
    <div id="popup" class="wraplightbox" style="margin:auto">
        <p onclick="hide_lightbox()" style="cursor:pointer">tutup</p>
        <div id="peta" style="height:300px; margin-bottom:10px; border:solid #999 2px;"></div>
    </div>
</body>
</html>
Share Improve this question asked May 29, 2013 at 8:14 Adem NaturalAdem Natural 1051 gold badge1 silver badge10 bronze badges 2
  • Try assigning a width (in px) to the map div (#peta). – Salman Arshad Commented May 29, 2013 at 8:32
  • I've tried it but it still does not work :D – Adem Natural Commented May 30, 2013 at 0:29
Add a ment  | 

2 Answers 2

Reset to default 1

Look at this question.

It has the right code for the popup of google maps.

I took a look at the first link 3dgoo told us. It's working great as people are using it like on this website: Pallas restaurant. The link is at the bottom-left for the popup of google maps.

---------------EDIT---------------

I did not tell the site where the code belongs, but here you go!

Create the division for the map inside the initilaser of colorbox.

var link = document.getElementById("seeMap");
link.colorbox({
        html: '<div id="MapPane" class="mapClass"></div>',
        scrolling: false,
        width: "1000px",
        onComplete: function(){
                     loadMap();
       }
})

function loadMap()
{
    var map = new google.maps.Map(document.getElementById("MapPane"),mapoptions);
}

This will work.

发布评论

评论列表(0)

  1. 暂无评论