传单无法创建标记

leaflet cannot create marker

我是 web 开发的新手,我在使用 leaflet 和 codeigniter 时遇到问题。问题是我无法创建标记。这是代码:

         <html>
    <head>
        <link rel="stylesheet" href="<?php echo base_url();?>dist/css/leaflet.css" />
        <link rel="stylesheet" href="<?php echo base_url();?>dist/css/main.css"/>
    </head>
    <body>
        <div id="map"></div>

    </body> </html>



<script src="<?php echo base_url();?>dist/js/leaflet.js"></script> <script src="<?php echo base_url();?>dist/js/jquery-1.11.0.js"></script>

<script>
    var map = L.map('map').setView([51.505, -0.09], 13);
    function createMarker(lat,long){


        var marker = L.marker([lat,long]).addTo(map);
    }



    $(function(){

       L.tileLayer( 'http://{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {           attribution: '&copy; <a href="http://osm.org/copyright" title="OpenStreetMap" target="_blank">OpenStreetMap</a> contributors | Tiles Courtesy of <a href="http://www.mapquest.com/" title="MapQuest" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png" width="16" height="16">',            subdomains: ['otile1','otile2','otile3','otile4']           }).addTo( map );
        $.getJSON('index.php/map/getData',function(data){

            debugger;
            for(i=0;i<3;i++)
            {
                var latitude = parseFloat(data[i].latitude);
                var longitude = parseFloat(data[i].longitude);
                createMarker(latitude,longitude);    
            }

        });
    }); </script>

这里是getjson中检索到的数据:

> [
Object
hasil_uji_id: 1
latitude: 51.13
longitude: -0.07
nama_hasil_uji: "iqbal 3"
__proto__: Object
, 
Object
hasil_uji_id: 123
latitude: 51.05
longitude: -0.09
nama_hasil_uji: "iqbal"
__proto__: Object
, 
Object
hasil_uji_id: 1234
latitude: 51.09
longitude: -0.08
nama_hasil_uji: "iqbal 2"
__proto__: Object
]

然而,当我硬编码纬度和经度的值时,标记出现了。请传单大师赐教

我的错误,一个非常愚蠢的错误,我感到羞耻。代码确实有效,标记没有显示,因为纬度和经度离 setView 太远了

当我缩小时,它们确实出现了。