如何使用传单创建一个jsfiddle

how to create a jsfiddle using leaflet

我正在努力使用 jsfiddle 尝试创建一个使用传单的 运行 示例。

因为我没有成功,所以我搜索了一些示例并发现以下示例有效:

然后我将示例复制到一个新的 fiddle

但还是不行...

插入外部资源时出现如下错误:

jsfiddle.net says:

You're loading resources over HTTP not HTTPS, your fiddle will not work. Do you wish to continue?

有什么建议这里有什么问题吗?

p.s.: 下面是js的代码fiddle windows:

HTML:

<div id="map"></div>

CSS:

#map {
    height: 500px;
    width: 80%;
}

JAVASCRIPT:

// We’ll add a tile layer to add to our map, in this case it’s a OSM tile layer.
// Creating a tile layer usually involves setting the URL template for the tile images
var osmUrl = 'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
      osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
      osm = L.tileLayer(osmUrl, {
        maxZoom: 18,
        attribution: osmAttrib
      });
// initialize the map on the "map" div with a given center and zoom
var map = L.map('map').setView([19.04469, 72.9258], 12).addLayer(osm);

// Script for adding marker on map click
function onMapClick(e) {
var marker = L.marker(e.latlng, {
    draggable: true,
    title: "Resource location",
    alt: "Resource Location",
    riseOnHover: true
    }).addTo(map)
    .bindPopup(e.latlng.toString()).openPopup();

    // Update marker on changing it's position
    marker.on("dragend", function(ev) {

    var chagedPos = ev.target.getLatLng();
    this.bindPopup(chagedPos.toString()).openPopup();

    });
    }
    map.on('click', onMapClick);

The Leaflet CDN doesn't support SSL yet. You can use something not requiring https, like playground-leaflet 这只是 JSBin 的一个分支,带有易于选择的传单库。

或者,您可以使用 Leaflet from cdnjs.net,它支持 https。