在codeigniter控制器中调用Ajax的映射加载

时间:2022-12-01 23:20:38

Map is not loading in my popup window. view/test.php file

我的弹出窗口中没有加载地图。 view / test.php文件

<script type="text/javascript">
      $(document).ready(function() {
    $(".popup_property").click(function(e){ //on add input button click
     var id = $(this).attr('href'); 
        $.post( "<?php echo base_url()?>admin/host/viewproperty/"+id , function( data ) {
  $( ".popupview1" ).html( data );
});

  });     
});
    </script>

Controller file:

控制器文件:

host.php controller file function viewProperty

host.php控制器文件函数viewProperty

function viewProperty()
    {
 .....
        $hostPreviewHtml = '<div id="map"  class="pagescroll col-xs-12 row">
                    <div style="height: 250px;
               " id="mapview"></div>                
                    </div>

                    </div></div>

    </div>
    <script type="text/javascript"> 
    var map;
    var marker;
    var myLatlng = new google.maps.LatLng(36.708006,-119.5559652)
    var geocoder = new google.maps.Geocoder();
    var infowindow = new google.maps.InfoWindow();
    function initialize(){
    var mapOptions = {
    zoom: 18,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    map = new google.maps.Map(document.getElementById("mapview"), mapOptions);

    marker = new google.maps.Marker({
    map: map,
    position: myLatlng,
    draggable: true 
    }); 
    }
    google.maps.event.addDomListener(window, "load", initialize);

    </script>
    ';
        echo $hostPreviewHtml;
        }

No console error . but map is not loading in popup window. please help me to solve this problem.

没有控制台错误。但是弹出窗口中没有加载地图。请帮我解决这个问题。

1 个解决方案

#1


0  

It looks like you didn't set the Maps JS script source.

看起来您没有设置Maps JS脚本源。

You can check out the Getting Started page of the Maps JS API and see if there are other items still missing from your implementation.

您可以查看Maps JS API的“入门”页面,看看您的实现是否还有其他项目丢失。

Happy coding!

快乐的编码!

#1


0  

It looks like you didn't set the Maps JS script source.

看起来您没有设置Maps JS脚本源。

You can check out the Getting Started page of the Maps JS API and see if there are other items still missing from your implementation.

您可以查看Maps JS API的“入门”页面,看看您的实现是否还有其他项目丢失。

Happy coding!

快乐的编码!