script.js
javascript
var map = L.map('map').setView([30.65, 104.06], 11);L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {attribution: '©
OpenStreetMap
contributors'
}).addTo(map);var data = [{"name": "青羊区","price": 25000},{"name": "金牛区","price": 23000},{"name": "武侯区","price": 28000},{"name": "成华区","price": 20000},{"name": "锦江区","price": 30000},{"name": "青白江区","price": 18000},{"name": "新都区","price": 16000},{"name": "龙泉驿区","price": 17000},{
"name": "温江区","price": 19000},{"name": "双流区","price": 22000},{"name": "高新区","price": 32000},{"name": "郫都区","price": 17000},{"name": "大邑县","price": 15000},{"name": "蒲江县","price": 14000},{"name": "金堂县","price": 16000},{"name": "简阳市","price": 13000},{"name": "都江堰市","price": 14000},{"name": "彭州市","price": 15000},{"name": "崇州市","price": 14000},{"name": "邛崃市","price": 13000},{"name": "新津市","price": 14000}
];for (var i = 0; i < data.length; i++) {var marker = L.marker([data[i].lat, data[i].lon]).addTo(map);marker.bindPopup("
" + data[i].name + "
" + data[i].price + "元/平米");
}