提交 f5284db4 编写于 作者: nengyuangzhang's avatar nengyuangzhang

changed map marker in myems-web

上级 cbe2a3cb
...@@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ...@@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added ### Added
- added hyperlink to meter name of Meter Batch report in myems-web - added hyperlink to meter name of Meter Batch report in myems-web
### Changed ### Changed
- changed map marker in myems-web
### Fixed ### Fixed
- added decimal data value range check to myems-modbus-tcp. - added decimal data value range check to myems-modbus-tcp.
### Removed ### Removed
......
...@@ -6,6 +6,7 @@ import MapboxLanguage from '@mapbox/mapbox-gl-language'; ...@@ -6,6 +6,7 @@ import MapboxLanguage from '@mapbox/mapbox-gl-language';
import 'mapbox-gl/dist/mapbox-gl.css'; import 'mapbox-gl/dist/mapbox-gl.css';
import { checkEmpty, getCookieValue } from '../../../helpers/utils'; import { checkEmpty, getCookieValue } from '../../../helpers/utils';
import { settings } from '../../../config'; import { settings } from '../../../config';
import map_maker from '../../../assets/img/icons/map-marker.png';
mapboxgl.accessToken = settings.mapboxToken; mapboxgl.accessToken = settings.mapboxToken;
if (mapboxgl.getRTLTextPluginStatus !== 'loaded') { if (mapboxgl.getRTLTextPluginStatus !== 'loaded') {
...@@ -37,7 +38,8 @@ const CustomizeMapBox = ({ Latitude, Longitude, Zoom, Geojson, t }) => { ...@@ -37,7 +38,8 @@ const CustomizeMapBox = ({ Latitude, Longitude, Zoom, Geojson, t }) => {
container: mapContainer.current, container: mapContainer.current,
zoom: Zoom ? Zoom : zoom, zoom: Zoom ? Zoom : zoom,
center: [Longitude ? Longitude : lng, Latitude ? Latitude : lat], center: [Longitude ? Longitude : lng, Latitude ? Latitude : lat],
style: isDark ? 'mapbox://styles/mapbox/dark-v10' : 'mapbox://styles/mapbox/streets-v11' // https://docs.mapbox.com/api/maps/styles/#mapbox-styles
style: isDark ? 'mapbox://styles/mapbox/dark-v11' : 'mapbox://styles/mapbox/streets-v12'
}); });
map.current.on('move', () => { map.current.on('move', () => {
...@@ -64,7 +66,7 @@ const CustomizeMapBox = ({ Latitude, Longitude, Zoom, Geojson, t }) => { ...@@ -64,7 +66,7 @@ const CustomizeMapBox = ({ Latitude, Longitude, Zoom, Geojson, t }) => {
container: mapContainer.current, container: mapContainer.current,
zoom: Zoom ? Zoom : zoom, zoom: Zoom ? Zoom : zoom,
center: [Longitude ? Longitude : lng, Latitude ? Latitude : lat], center: [Longitude ? Longitude : lng, Latitude ? Latitude : lat],
style: isDark ? 'mapbox://styles/mapbox/dark-v10' : 'mapbox://styles/mapbox/streets-v11' style: isDark ? 'mapbox://styles/mapbox/dark-v11' : 'mapbox://styles/mapbox/streets-v12'
}); });
map.current.on('move', () => { map.current.on('move', () => {
...@@ -80,7 +82,14 @@ const CustomizeMapBox = ({ Latitude, Longitude, Zoom, Geojson, t }) => { ...@@ -80,7 +82,14 @@ const CustomizeMapBox = ({ Latitude, Longitude, Zoom, Geojson, t }) => {
map.current.addControl(mapboxLanguage); map.current.addControl(mapboxLanguage);
map.current.on('load', () => { map.current.on('load', () => {
map.current.addSource('earthquakes', { map.current.loadImage(
map_maker,
(error, image) => {
if (error) throw error;
map.current.addImage('map-marker', image);
}
);
map.current.addSource('myems', {
type: 'geojson', type: 'geojson',
data: { data: {
type: 'FeatureCollection', type: 'FeatureCollection',
...@@ -94,7 +103,7 @@ const CustomizeMapBox = ({ Latitude, Longitude, Zoom, Geojson, t }) => { ...@@ -94,7 +103,7 @@ const CustomizeMapBox = ({ Latitude, Longitude, Zoom, Geojson, t }) => {
map.current.addLayer({ map.current.addLayer({
id: 'clusters', id: 'clusters',
type: 'circle', type: 'circle',
source: 'earthquakes', source: 'myems',
filter: ['has', 'point_count'], filter: ['has', 'point_count'],
paint: { paint: {
// Use step expressions (https://docs.mapbox.com/style-spec/reference/expressions/#step) // Use step expressions (https://docs.mapbox.com/style-spec/reference/expressions/#step)
...@@ -110,7 +119,7 @@ const CustomizeMapBox = ({ Latitude, Longitude, Zoom, Geojson, t }) => { ...@@ -110,7 +119,7 @@ const CustomizeMapBox = ({ Latitude, Longitude, Zoom, Geojson, t }) => {
map.current.addLayer({ map.current.addLayer({
id: 'cluster-count', id: 'cluster-count',
type: 'symbol', type: 'symbol',
source: 'earthquakes', source: 'myems',
filter: ['has', 'point_count'], filter: ['has', 'point_count'],
layout: { layout: {
'text-field': ['get', 'point_count_abbreviated'], 'text-field': ['get', 'point_count_abbreviated'],
...@@ -121,14 +130,12 @@ const CustomizeMapBox = ({ Latitude, Longitude, Zoom, Geojson, t }) => { ...@@ -121,14 +130,12 @@ const CustomizeMapBox = ({ Latitude, Longitude, Zoom, Geojson, t }) => {
map.current.addLayer({ map.current.addLayer({
id: 'unclustered-point', id: 'unclustered-point',
type: 'circle', type: 'symbol',
source: 'earthquakes', source: 'myems',
filter: ['!', ['has', 'point_count']], filter: ['!', ['has', 'point_count']],
paint: { 'layout': {
'circle-color': '#11b4da', 'icon-image': 'map-marker',
'circle-radius': 10, "icon-size": 0.5
'circle-stroke-width': 1,
'circle-stroke-color': '#fff'
} }
}); });
...@@ -138,7 +145,7 @@ const CustomizeMapBox = ({ Latitude, Longitude, Zoom, Geojson, t }) => { ...@@ -138,7 +145,7 @@ const CustomizeMapBox = ({ Latitude, Longitude, Zoom, Geojson, t }) => {
layers: ['clusters'] layers: ['clusters']
}); });
const clusterId = features[0].properties.cluster_id; const clusterId = features[0].properties.cluster_id;
map.current.getSource('earthquakes').getClusterExpansionZoom(clusterId, (err, zoom) => { map.current.getSource('myems').getClusterExpansionZoom(clusterId, (err, zoom) => {
if (err) return; if (err) return;
map.current.easeTo({ map.current.easeTo({
zoom: zoom, zoom: zoom,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册