首页 > 代码库 > leaflet入门(三)使用GeoJSON创建矢量图形
leaflet入门(三)使用GeoJSON创建矢量图形
点对象:
function g(feature, layer) { // does this feature have a property named popupContent? if (feature.properties && feature.properties.popupContent) { layer.bindPopup(feature.properties.popupContent); } } var geojsonFeature = { "type": "Feature", "properties": { "name": "Coors Field", "amenity": "Baseball Stadium", "popupContent": "This is where the Rockies play!" }, "geometry": { "type": "Point", "coordinates": [100, 31] } }; L.geoJSON(geojsonFeature, { onEachFeature: g }).addTo(map);
线要素:
var draw_line = { "type": "Feature", "geometry": { "type": "LineString", "coordinates": [ [110, 11], [110, 49] ] }, "properties": { "popupContent": "This is a free bus line that will take you across downtown.", "underConstruction": true }, "id": 2 }; //绑定事件 function f(feature, layer) { layer.bindPopup(feature.properties.popupContent); } //增加到地图 var ss = L.geoJson(draw_line, { style: { "color": ‘black‘, "weight": 1 }, onEachFeature: f }).addTo(map);
leaflet入门(三)使用GeoJSON创建矢量图形
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。