tiles都是完整的html,GeojsonTiles.html

Leaflet1

body {

margin: 0px;

padding: 0px;

}

/**

* 单独设置mapid为100%不显示,可能float坍塌

*/

html,

body,

#mapDiv {

height: 100%;

width: 100%;

}

//地图地址

var url = 'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw';

var attr = ' Map data © OpenStreetMap contributors, © CartoDB';

var lon = 121.8170896;

var lat = 31.1471532;

var leafletMap = L.map('mapDiv').setView([lat, lon], 10);

//图层

L.tileLayer(url, {

maxZoom: 18,

attribution: attr,

id: 'mapbox.streets'

}).addTo(leafletMap);

var style = {

"clickable": true,

"color": "#00D",

"fillColor": "#00D",

"weight": 1.0,

"opacity": 0.3,

"fillOpacity": 0.2

};

var hoverStyle = {

"fillOpacity": 0.5

};

var geojsonURL = 'http://localhost:8080/tiles/{z}/{x}/{y}.geojson';

var geojsonTileLayer = new L.TileLayer.GeoJSON(geojsonURL, {

clipTiles: true,

unique: function (feature) {

return feature.id;

}

}, {

style: style,

onEachFeature: function (feature, layer) {

if (feature.properties) {

var popupString = '

';

layer.bindPopup(popupString);

}

if (!(layer instanceof L.Point)) {

layer.on('mouseover', function () {

layer.setStyle(hoverStyle);

});

layer.on('mouseout', function () {

layer.setStyle(style);

});

}

}

}

);

leafletMap.addLayer(geojsonTileLayer);

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值