diff --git a/front/index.js b/front/index.js index d61a895..bf43506 100644 --- a/front/index.js +++ b/front/index.js @@ -1,12 +1,32 @@ import L from 'leaflet'; import 'leaflet/dist/leaflet.css'; -var map = L.map('map', { +let map = L.map('map', { crs: L.CRS.Simple, minZoom: -4 }); -var bounds = [[0,0], [15360, 15360]]; -var image = L.imageOverlay('./maps/Tanoa.png', bounds).addTo(map); - +let bounds = [[0,0], [15360, 15360]]; +let image = L.imageOverlay('./maps/Tanoa.png', bounds).addTo(map); map.fitBounds(bounds); + +function makeIcon() { + let markerIcon = L.icon({ + iconSize: [30, 30], + iconAnchor: [15, 15], + iconUrl: './marker/dot.png' + }); + return markerIcon; +} + +function makeMarker(coord, text) { + let [x, y] = coord; + let marker = L.marker(L.latLng(y, x), {icon: makeIcon(text)}); + // https://gis.stackexchange.com/questions/59571/how-to-add-text-only-labels-on-leaflet-map-with-no-icon + marker.bindTooltip(text, {permanent: true, offset: [15, 0]}); + return marker; +} + +let marker1 = makeMarker([0, 0], "测试aaaaaaaaaaaaaaaaa bbbbbbbbbb cccc"); +marker1.addTo(map); + diff --git a/front/package-lock.json b/front/package-lock.json index 26d2387..e6d9725 100644 --- a/front/package-lock.json +++ b/front/package-lock.json @@ -2459,6 +2459,21 @@ "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.6.0.tgz", "integrity": "sha512-CPkhyqWUKZKFJ6K8umN5/D2wrJ2+/8UIpXppY7QDnUZW5bZL5+SEI2J7GBpwh4LIupOKqbNSQXgqmrEJopHVNQ==" }, + "leaflet.label": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/leaflet.label/-/leaflet.label-0.2.4.tgz", + "integrity": "sha1-BnZZmvDA2YFhnLiAlWNvyb9xFRs=", + "requires": { + "leaflet": "0.7.7" + }, + "dependencies": { + "leaflet": { + "version": "0.7.7", + "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-0.7.7.tgz", + "integrity": "sha1-HjUrpU5j0HZFH6NjyQCJDLLPde4=" + } + } + }, "loader-runner": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-2.4.0.tgz", diff --git a/front/package.json b/front/package.json index dc0314e..490d779 100644 --- a/front/package.json +++ b/front/package.json @@ -16,6 +16,7 @@ "webpack-cli": "^3.3.11" }, "dependencies": { - "leaflet": "^1.6.0" + "leaflet": "^1.6.0", + "leaflet.label": "^0.2.4" } } diff --git a/static/marker/blue.png b/static/marker/blue.png new file mode 100644 index 0000000..7df9c56 Binary files /dev/null and b/static/marker/blue.png differ diff --git a/static/marker/dot.png b/static/marker/dot.png new file mode 100644 index 0000000..f2531c2 Binary files /dev/null and b/static/marker/dot.png differ diff --git a/static/marker/green.png b/static/marker/green.png new file mode 100644 index 0000000..9f18793 Binary files /dev/null and b/static/marker/green.png differ diff --git a/static/marker/loc_blue.png b/static/marker/loc_blue.png new file mode 100644 index 0000000..5893322 Binary files /dev/null and b/static/marker/loc_blue.png differ diff --git a/static/marker/loc_red.png b/static/marker/loc_red.png new file mode 100644 index 0000000..1f921f6 Binary files /dev/null and b/static/marker/loc_red.png differ diff --git a/static/marker/purple.png b/static/marker/purple.png new file mode 100644 index 0000000..92ed9d3 Binary files /dev/null and b/static/marker/purple.png differ diff --git a/static/marker/red.png b/static/marker/red.png new file mode 100644 index 0000000..f2531c2 Binary files /dev/null and b/static/marker/red.png differ