mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-07 18:03:48 +00:00
feat: optimize code
This commit is contained in:
@@ -47,7 +47,7 @@ const FileOrFolderFilter = ({ readOnly, value = 'all', onChange: onChangeAPI })
|
|||||||
return (
|
return (
|
||||||
<CustomizeSelect
|
<CustomizeSelect
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
className="sf-metadata-basic-filters-select"
|
className="sf-metadata-basic-filters-select mr-4"
|
||||||
value={displayValue}
|
value={displayValue}
|
||||||
options={options}
|
options={options}
|
||||||
onSelectOption={onChange}
|
onSelectOption={onChange}
|
||||||
|
@@ -47,7 +47,7 @@ const GalleryFileTypeFilter = ({ readOnly, value = 'picture', onChange: onChange
|
|||||||
return (
|
return (
|
||||||
<CustomizeSelect
|
<CustomizeSelect
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
className="sf-metadata-basic-filters-select sf-metadata-table-view-basic-filter-file-type-select ml-4"
|
className="sf-metadata-basic-filters-select sf-metadata-table-view-basic-filter-file-type-select mr-4"
|
||||||
value={displayValue}
|
value={displayValue}
|
||||||
options={options}
|
options={options}
|
||||||
onSelectOption={onChange}
|
onSelectOption={onChange}
|
||||||
|
@@ -54,7 +54,7 @@ const TableFileTypeFilter = ({ readOnly, value, onChange: onChangeAPI }) => {
|
|||||||
return (
|
return (
|
||||||
<CustomizeSelect
|
<CustomizeSelect
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
className="sf-metadata-basic-filters-select sf-metadata-table-view-basic-filter-file-type-select ml-4"
|
className="sf-metadata-basic-filters-select sf-metadata-table-view-basic-filter-file-type-select mr-4"
|
||||||
value={displayValue}
|
value={displayValue}
|
||||||
options={options}
|
options={options}
|
||||||
onSelectOption={onChange}
|
onSelectOption={onChange}
|
||||||
|
@@ -84,7 +84,7 @@ const TagsFilter = ({ readOnly, value: oldValue, onChange: onChangeAPI }) => {
|
|||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
searchable={true}
|
searchable={true}
|
||||||
supportMultipleSelect={true}
|
supportMultipleSelect={true}
|
||||||
className="sf-metadata-basic-filters-select sf-metadata-table-view-basic-filter-file-type-select ml-4"
|
className="sf-metadata-basic-filters-select sf-metadata-table-view-basic-filter-file-type-select mr-4"
|
||||||
value={displayValue}
|
value={displayValue}
|
||||||
options={options}
|
options={options}
|
||||||
onSelectOption={onChange}
|
onSelectOption={onChange}
|
||||||
|
@@ -38,6 +38,7 @@ const MapViewToolBar = ({
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
setShowGalleryToolbar(false);
|
||||||
const unsubscribeToggle = window.sfMetadataContext.eventBus.subscribe(EVENT_BUS_TYPE.TOGGLE_VIEW_TOOLBAR, onToggle);
|
const unsubscribeToggle = window.sfMetadataContext.eventBus.subscribe(EVENT_BUS_TYPE.TOGGLE_VIEW_TOOLBAR, onToggle);
|
||||||
const unsubscribeView = window.sfMetadataContext.eventBus.subscribe(EVENT_BUS_TYPE.RESET_VIEW, resetView);
|
const unsubscribeView = window.sfMetadataContext.eventBus.subscribe(EVENT_BUS_TYPE.RESET_VIEW, resetView);
|
||||||
return () => {
|
return () => {
|
||||||
@@ -45,10 +46,6 @@ const MapViewToolBar = ({
|
|||||||
unsubscribeView && unsubscribeView();
|
unsubscribeView && unsubscribeView();
|
||||||
};
|
};
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setShowGalleryToolbar(false);
|
|
||||||
}, [viewID]);
|
}, [viewID]);
|
||||||
|
|
||||||
if (showGalleryToolbar) {
|
if (showGalleryToolbar) {
|
||||||
|
@@ -85,12 +85,17 @@ const ClusterPhotos = ({ markerIds, onClose }) => {
|
|||||||
}, [metadata, repoID, viewID, store, loadData]);
|
}, [metadata, repoID, viewID, store, loadData]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const unsubscribeViewChange = window.sfMetadataContext.eventBus.subscribe(EVENT_BUS_TYPE.UPDATE_SERVER_VIEW, onViewChange);
|
|
||||||
window.sfMetadataContext.eventBus.dispatch(EVENT_BUS_TYPE.TOGGLE_VIEW_TOOLBAR, true);
|
window.sfMetadataContext.eventBus.dispatch(EVENT_BUS_TYPE.TOGGLE_VIEW_TOOLBAR, true);
|
||||||
return () => {
|
return () => {
|
||||||
unsubscribeViewChange();
|
|
||||||
window?.sfMetadataContext?.eventBus?.dispatch(EVENT_BUS_TYPE.TOGGLE_VIEW_TOOLBAR, false);
|
window?.sfMetadataContext?.eventBus?.dispatch(EVENT_BUS_TYPE.TOGGLE_VIEW_TOOLBAR, false);
|
||||||
};
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const unsubscribeViewChange = window?.sfMetadataContext?.eventBus?.subscribe(EVENT_BUS_TYPE.UPDATE_SERVER_VIEW, onViewChange);
|
||||||
|
return () => {
|
||||||
|
unsubscribeViewChange && unsubscribeViewChange();
|
||||||
|
};
|
||||||
}, [onViewChange]);
|
}, [onViewChange]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
import { mediaUrl } from '../../../../utils/constants';
|
import { mediaUrl } from '../../../../utils/constants';
|
||||||
import { Utils } from '../../../../utils/utils';
|
import { Utils } from '../../../../utils/utils';
|
||||||
|
|
||||||
export function createBMapGeolocationControl(BMap, callback) {
|
export function createBMapGeolocationControl(BMapGL, callback) {
|
||||||
function GeolocationControl() {
|
function GeolocationControl() {
|
||||||
this.defaultAnchor = window.BMAP_ANCHOR_BOTTOM_RIGHT;
|
this.defaultAnchor = window.BMAP_ANCHOR_BOTTOM_RIGHT;
|
||||||
this.defaultOffset = new BMap.Size(30, Utils.isDesktop() ? 30 : 90);
|
this.defaultOffset = new BMapGL.Size(30, Utils.isDesktop() ? 30 : 90);
|
||||||
}
|
}
|
||||||
GeolocationControl.prototype = new window.BMap.Control();
|
GeolocationControl.prototype = new BMapGL.Control();
|
||||||
GeolocationControl.prototype.initialize = function (map) {
|
GeolocationControl.prototype.initialize = function (map) {
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
div.className = 'sf-BMap-geolocation-control';
|
div.className = 'sf-BMap-geolocation-control';
|
||||||
@@ -24,7 +24,7 @@ export function createBMapGeolocationControl(BMap, callback) {
|
|||||||
}
|
}
|
||||||
div.onclick = (e) => {
|
div.onclick = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const geolocation = new BMap.Geolocation();
|
const geolocation = new BMapGL.Geolocation();
|
||||||
div.className = 'sf-BMap-geolocation-control sf-BMap-geolocation-control-loading';
|
div.className = 'sf-BMap-geolocation-control sf-BMap-geolocation-control-loading';
|
||||||
geolocation.getCurrentPosition((result) => {
|
geolocation.getCurrentPosition((result) => {
|
||||||
div.className = 'sf-BMap-geolocation-control';
|
div.className = 'sf-BMap-geolocation-control';
|
||||||
|
@@ -1,11 +1,14 @@
|
|||||||
import { Utils } from '../../../../utils/utils';
|
import { Utils } from '../../../../utils/utils';
|
||||||
|
|
||||||
export function createBMapZoomControl(BMap, callback) {
|
const maxZoom = 18;
|
||||||
|
const minZoom = 3;
|
||||||
|
|
||||||
|
export function createBMapZoomControl(BMapGL, callback) {
|
||||||
function ZoomControl() {
|
function ZoomControl() {
|
||||||
this.defaultAnchor = window.BMAP_ANCHOR_BOTTOM_RIGHT;
|
this.defaultAnchor = window.BMAP_ANCHOR_BOTTOM_RIGHT;
|
||||||
this.defaultOffset = new BMap.Size(80, Utils.isDesktop() ? 30 : 90);
|
this.defaultOffset = new BMapGL.Size(80, Utils.isDesktop() ? 30 : 90);
|
||||||
}
|
}
|
||||||
ZoomControl.prototype = new window.BMap.Control();
|
ZoomControl.prototype = new BMapGL.Control();
|
||||||
ZoomControl.prototype.initialize = function (map) {
|
ZoomControl.prototype.initialize = function (map) {
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
div.className = 'sf-BMap-zoom-control';
|
div.className = 'sf-BMap-zoom-control';
|
||||||
@@ -35,21 +38,21 @@ export function createBMapZoomControl(BMap, callback) {
|
|||||||
|
|
||||||
const updateButtonStates = () => {
|
const updateButtonStates = () => {
|
||||||
const zoomLevel = map.getZoom();
|
const zoomLevel = map.getZoom();
|
||||||
const maxZoom = map.getMapType().getMaxZoom();
|
|
||||||
const minZoom = map.getMapType().getMinZoom();
|
|
||||||
|
|
||||||
zoomInButton.disabled = zoomLevel >= maxZoom;
|
zoomInButton.disabled = zoomLevel >= maxZoom;
|
||||||
zoomOutButton.disabled = zoomLevel <= minZoom;
|
zoomOutButton.disabled = zoomLevel <= minZoom;
|
||||||
|
callback && callback(zoomLevel);
|
||||||
};
|
};
|
||||||
|
|
||||||
zoomInButton.onclick = (e) => {
|
zoomInButton.onclick = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
map.zoomTo(map.getZoom() + 2);
|
const nextZoom = map.getZoom() + 2;
|
||||||
|
map.zoomTo(Math.min(nextZoom, maxZoom));
|
||||||
};
|
};
|
||||||
|
|
||||||
zoomOutButton.onclick = (e) => {
|
zoomOutButton.onclick = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
map.zoomTo(map.getZoom() - 2);
|
const nextZoom = map.getZoom() - 2;
|
||||||
|
map.zoomTo(Math.max(nextZoom, minZoom));
|
||||||
};
|
};
|
||||||
|
|
||||||
map.addEventListener('zoomend', updateButtonStates);
|
map.addEventListener('zoomend', updateButtonStates);
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
.sf-metadata-view-map .custom-image-number {
|
.sf-metadata-view-map .custom-image-number {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: -15px;
|
right: -16px;
|
||||||
top: -16px;
|
top: -16px;
|
||||||
width: 32px;
|
width: 32px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
@@ -39,6 +39,7 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sf-metadata-view-map .custom-image-container:active::before,
|
.sf-metadata-view-map .custom-image-container:active::before,
|
||||||
|
@@ -45,6 +45,7 @@ const Map = () => {
|
|||||||
clusterRef.current = clusterIds;
|
clusterRef.current = clusterIds;
|
||||||
updateCurrentPath(`/${PRIVATE_FILE_TYPE.FILE_EXTENDED_PROPERTIES}/${viewID}/${gettext('Location')}`);
|
updateCurrentPath(`/${PRIVATE_FILE_TYPE.FILE_EXTENDED_PROPERTIES}/${viewID}/${gettext('Location')}`);
|
||||||
setShowCluster(true);
|
setShowCluster(true);
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [viewID, updateCurrentPath]);
|
}, [viewID, updateCurrentPath]);
|
||||||
|
|
||||||
const closeCluster = useCallback(() => {
|
const closeCluster = useCallback(() => {
|
||||||
@@ -56,7 +57,7 @@ const Map = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
updateCurrentPath(`/${PRIVATE_FILE_TYPE.FILE_EXTENDED_PROPERTIES}/${viewID}`);
|
updateCurrentPath(`/${PRIVATE_FILE_TYPE.FILE_EXTENDED_PROPERTIES}/${viewID}`);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [viewID]);
|
}, []);
|
||||||
|
|
||||||
if (showCluster) {
|
if (showCluster) {
|
||||||
return (<ClusterPhotos markerIds={clusterRef.current} onClose={closeCluster} />);
|
return (<ClusterPhotos markerIds={clusterRef.current} onClose={closeCluster} />);
|
||||||
|
@@ -1,30 +1,37 @@
|
|||||||
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import loadBMap, { initMapInfo } from '../../../utils/map-utils';
|
import loadBMap, { initMapInfo } from '../../../utils/map-utils';
|
||||||
import { appAvatarURL, baiduMapKey, gettext, googleMapKey, mediaUrl } from '../../../utils/constants';
|
import { appAvatarURL, baiduMapKey, googleMapKey, mediaUrl } from '../../../utils/constants';
|
||||||
import { isValidPosition } from '../../utils/validate';
|
import { isValidPosition } from '../../utils/validate';
|
||||||
import { wgs84_to_gcj02, gcj02_to_bd09 } from '../../../utils/coord-transform';
|
import { wgs84_to_gcj02, gcj02_to_bd09 } from '../../../utils/coord-transform';
|
||||||
import { MAP_TYPE as MAP_PROVIDER } from '../../../constants';
|
import { MAP_TYPE as MAP_PROVIDER } from '../../../constants';
|
||||||
import { EVENT_BUS_TYPE, MAP_TYPE, STORAGE_MAP_CENTER_KEY, STORAGE_MAP_TYPE_KEY, STORAGE_MAP_ZOOM_KEY } from '../../constants';
|
import { EVENT_BUS_TYPE, MAP_TYPE, STORAGE_MAP_CENTER_KEY, STORAGE_MAP_TYPE_KEY, STORAGE_MAP_ZOOM_KEY } from '../../constants';
|
||||||
import { createBMapGeolocationControl, createBMapZoomControl } from './control';
|
import { createBMapGeolocationControl, createBMapZoomControl } from './control';
|
||||||
import { customAvatarOverlay, customImageOverlay } from './overlay';
|
import { customAvatarOverlay, customImageOverlay } from './overlay';
|
||||||
import toaster from '../../../components/toast';
|
|
||||||
|
|
||||||
const DEFAULT_POSITION = { lng: 104.195, lat: 35.861 };
|
const DEFAULT_POSITION = { lng: 104.195, lat: 35.861 };
|
||||||
const DEFAULT_ZOOM = 4;
|
const DEFAULT_ZOOM = 4;
|
||||||
const BATCH_SIZE = 500;
|
const BATCH_SIZE = 500;
|
||||||
|
|
||||||
const Main = ({ images, onOpenCluster }) => {
|
const Map = ({ images, onOpenCluster }) => {
|
||||||
const mapInfo = useMemo(() => initMapInfo({ baiduMapKey, googleMapKey }), []);
|
const mapInfo = useMemo(() => initMapInfo({ baiduMapKey, googleMapKey }), []);
|
||||||
|
|
||||||
const mapRef = useRef(null);
|
const mapRef = useRef(null);
|
||||||
const clusterRef = useRef(null);
|
const clusterRef = useRef(null);
|
||||||
const batchIndexRef = useRef(0);
|
const batchIndexRef = useRef(0);
|
||||||
|
|
||||||
|
const saveMapState = useCallback(() => {
|
||||||
|
if (!mapRef.current) return;
|
||||||
|
const point = mapRef.current.getCenter && mapRef.current.getCenter();
|
||||||
|
const zoom = mapRef.current.getZoom && mapRef.current.getZoom();
|
||||||
|
window.sfMetadataContext.localStorage.setItem(STORAGE_MAP_CENTER_KEY, point);
|
||||||
|
window.sfMetadataContext.localStorage.setItem(STORAGE_MAP_ZOOM_KEY, zoom);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const addMapController = useCallback(() => {
|
const addMapController = useCallback(() => {
|
||||||
const ZoomControl = createBMapZoomControl(window.BMap);
|
const ZoomControl = createBMapZoomControl(window.BMapGL, saveMapState);
|
||||||
const zoomControl = new ZoomControl();
|
const zoomControl = new ZoomControl();
|
||||||
const GeolocationControl = createBMapGeolocationControl(window.BMap, (err, point) => {
|
const GeolocationControl = createBMapGeolocationControl(window.BMapGL, (err, point) => {
|
||||||
if (!err && point) {
|
if (!err && point) {
|
||||||
mapRef.current.setCenter({ lng: point.lng, lat: point.lat });
|
mapRef.current.setCenter({ lng: point.lng, lat: point.lat });
|
||||||
}
|
}
|
||||||
@@ -34,37 +41,20 @@ const Main = ({ images, onOpenCluster }) => {
|
|||||||
|
|
||||||
mapRef.current.addControl(zoomControl);
|
mapRef.current.addControl(zoomControl);
|
||||||
mapRef.current.addControl(geolocationControl);
|
mapRef.current.addControl(geolocationControl);
|
||||||
}, []);
|
}, [saveMapState]);
|
||||||
|
|
||||||
const initializeUserMarker = useCallback(() => {
|
const initializeUserMarker = useCallback((centerPoint) => {
|
||||||
if (!window.BMap) return;
|
if (!window.BMapGL || !mapRef.current) return;
|
||||||
|
const imageUrl = `${mediaUrl}img/marker.png`;
|
||||||
const imageUrl = `${mediaUrl}/img/marker.png`;
|
const avatarMarker = customAvatarOverlay(centerPoint, appAvatarURL, imageUrl);
|
||||||
const addMarker = (lng, lat) => {
|
mapRef.current.addOverlay(avatarMarker);
|
||||||
const gcPosition = wgs84_to_gcj02(lng, lat);
|
setTimeout(() => mapRef.current.showOverlayContainer(), 3000);
|
||||||
const bdPosition = gcj02_to_bd09(gcPosition.lng, gcPosition.lat);
|
|
||||||
const point = new window.BMap.Point(bdPosition.lng, bdPosition.lat);
|
|
||||||
const avatarMarker = customAvatarOverlay(point, appAvatarURL, imageUrl);
|
|
||||||
mapRef.current && mapRef.current.addOverlay(avatarMarker);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!navigator.geolocation) {
|
|
||||||
addMarker(DEFAULT_POSITION.lng, DEFAULT_POSITION.lat);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
navigator.geolocation.getCurrentPosition(
|
|
||||||
position => addMarker(position.coords.longitude, position.coords.latitude),
|
|
||||||
() => {
|
|
||||||
addMarker(DEFAULT_POSITION.lng, DEFAULT_POSITION.lat);
|
|
||||||
toaster.danger(gettext('Failed to get user location'));
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const getBMapType = useCallback((type) => {
|
const getBMapType = useCallback((type) => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case MAP_TYPE.SATELLITE: {
|
case MAP_TYPE.SATELLITE: {
|
||||||
return window.BMAP_SATELLITE_MAP;
|
return window.BMAP_EARTH_MAP;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
return window.BMAP_NORMAL_MAP;
|
return window.BMAP_NORMAL_MAP;
|
||||||
@@ -72,14 +62,6 @@ const Main = ({ images, onOpenCluster }) => {
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const saveMapState = useCallback(() => {
|
|
||||||
if (!mapRef.current) return;
|
|
||||||
const point = mapRef.current.getCenter && mapRef.current.getCenter();
|
|
||||||
const zoom = mapRef.current.getZoom && mapRef.current.getZoom();
|
|
||||||
window.sfMetadataContext.localStorage.setItem(STORAGE_MAP_CENTER_KEY, point);
|
|
||||||
window.sfMetadataContext.localStorage.setItem(STORAGE_MAP_ZOOM_KEY, zoom);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const loadMapState = useCallback(() => {
|
const loadMapState = useCallback(() => {
|
||||||
const savedCenter = window.sfMetadataContext.localStorage.getItem(STORAGE_MAP_CENTER_KEY) || DEFAULT_POSITION;
|
const savedCenter = window.sfMetadataContext.localStorage.getItem(STORAGE_MAP_CENTER_KEY) || DEFAULT_POSITION;
|
||||||
const savedZoom = window.sfMetadataContext.localStorage.getItem(STORAGE_MAP_ZOOM_KEY) || DEFAULT_ZOOM;
|
const savedZoom = window.sfMetadataContext.localStorage.getItem(STORAGE_MAP_ZOOM_KEY) || DEFAULT_ZOOM;
|
||||||
@@ -88,8 +70,7 @@ const Main = ({ images, onOpenCluster }) => {
|
|||||||
|
|
||||||
const onClickMarker = useCallback((e, markers) => {
|
const onClickMarker = useCallback((e, markers) => {
|
||||||
saveMapState();
|
saveMapState();
|
||||||
|
const imageIds = markers.map(marker => marker._id);
|
||||||
const imageIds = markers.map(marker => marker._imageId);
|
|
||||||
onOpenCluster(imageIds);
|
onOpenCluster(imageIds);
|
||||||
}, [onOpenCluster, saveMapState]);
|
}, [onOpenCluster, saveMapState]);
|
||||||
|
|
||||||
@@ -103,7 +84,7 @@ const Main = ({ images, onOpenCluster }) => {
|
|||||||
for (let i = startIndex; i < endIndex; i++) {
|
for (let i = startIndex; i < endIndex; i++) {
|
||||||
const image = images[i];
|
const image = images[i];
|
||||||
const { lng, lat } = image;
|
const { lng, lat } = image;
|
||||||
const point = new window.BMap.Point(lng, lat);
|
const point = new window.BMapGL.Point(lng, lat);
|
||||||
const marker = customImageOverlay(point, image, {
|
const marker = customImageOverlay(point, image, {
|
||||||
callback: (e, markers) => onClickMarker(e, markers)
|
callback: (e, markers) => onClickMarker(e, markers)
|
||||||
});
|
});
|
||||||
@@ -126,42 +107,45 @@ const Main = ({ images, onOpenCluster }) => {
|
|||||||
}, [onClickMarker]);
|
}, [onClickMarker]);
|
||||||
|
|
||||||
const renderBaiduMap = useCallback(() => {
|
const renderBaiduMap = useCallback(() => {
|
||||||
if (!mapRef.current || !window.BMap.Map) return;
|
if (!mapRef.current || !window.BMapGL.Map) return;
|
||||||
let { center, zoom } = loadMapState();
|
let { center, zoom } = loadMapState();
|
||||||
// ask for user location
|
// ask for user location
|
||||||
if (navigator.geolocation) {
|
if (navigator.geolocation) {
|
||||||
navigator.geolocation.getCurrentPosition((userInfo) => {
|
navigator.geolocation.getCurrentPosition((userInfo) => {
|
||||||
center = { lng: userInfo.coords.longitude, lat: userInfo.coords.latitude };
|
center = { lng: userInfo.coords.longitude, lat: userInfo.coords.latitude };
|
||||||
window.sfMetadataContext.localStorage.setItem(STORAGE_MAP_CENTER_KEY, center);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (!isValidPosition(center?.lng, center?.lat)) return;
|
|
||||||
|
|
||||||
const gcPosition = wgs84_to_gcj02(center.lng, center.lat);
|
const gcPosition = wgs84_to_gcj02(center.lng, center.lat);
|
||||||
const bdPosition = gcj02_to_bd09(gcPosition.lng, gcPosition.lat);
|
const bdPosition = gcj02_to_bd09(gcPosition.lng, gcPosition.lat);
|
||||||
const { lng, lat } = bdPosition;
|
const { lng, lat } = bdPosition;
|
||||||
|
center = new window.BMapGL.Point(lng, lat);
|
||||||
|
window.sfMetadataContext.localStorage.setItem(STORAGE_MAP_CENTER_KEY, center);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const mapTypeValue = window.sfMetadataContext.localStorage.getItem(STORAGE_MAP_TYPE_KEY);
|
||||||
|
mapRef.current = new window.BMapGL.Map('sf-metadata-map-container', {
|
||||||
|
enableMapClick: false,
|
||||||
|
mapType: getBMapType(mapTypeValue)
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isValidPosition(center?.lng, center?.lat)) {
|
||||||
|
mapRef.current.centerAndZoom(center, zoom);
|
||||||
|
}
|
||||||
|
|
||||||
mapRef.current = new window.BMap.Map('sf-metadata-map-container', { enableMapClick: false });
|
|
||||||
const point = new window.BMap.Point(lng, lat);
|
|
||||||
mapRef.current.centerAndZoom(point, zoom);
|
|
||||||
mapRef.current.enableScrollWheelZoom(true);
|
mapRef.current.enableScrollWheelZoom(true);
|
||||||
|
|
||||||
|
initializeUserMarker(center);
|
||||||
const savedValue = window.sfMetadataContext.localStorage.getItem(STORAGE_MAP_TYPE_KEY);
|
|
||||||
mapRef.current && mapRef.current.setMapType(getBMapType(savedValue));
|
|
||||||
|
|
||||||
addMapController();
|
|
||||||
initializeUserMarker();
|
|
||||||
initializeCluster();
|
initializeCluster();
|
||||||
|
|
||||||
batchIndexRef.current = 0;
|
batchIndexRef.current = 0;
|
||||||
renderMarkersBatch();
|
renderMarkersBatch();
|
||||||
|
|
||||||
|
addMapController();
|
||||||
}, [addMapController, initializeCluster, initializeUserMarker, renderMarkersBatch, getBMapType, loadMapState]);
|
}, [addMapController, initializeCluster, initializeUserMarker, renderMarkersBatch, getBMapType, loadMapState]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const modifyMapTypeSubscribe = window.sfMetadataContext.eventBus.subscribe(EVENT_BUS_TYPE.MODIFY_MAP_TYPE, (newType) => {
|
const modifyMapTypeSubscribe = window.sfMetadataContext.eventBus.subscribe(EVENT_BUS_TYPE.MODIFY_MAP_TYPE, (newType) => {
|
||||||
window.sfMetadataContext.localStorage.setItem(STORAGE_MAP_TYPE_KEY, newType);
|
window.sfMetadataContext.localStorage.setItem(STORAGE_MAP_TYPE_KEY, newType);
|
||||||
mapRef.current && mapRef.current.setMapType(getBMapType(newType));
|
const mapType = getBMapType(newType);
|
||||||
|
mapRef.current && mapRef.current.setMapType(mapType);
|
||||||
});
|
});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
@@ -179,7 +163,8 @@ const Main = ({ images, onOpenCluster }) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}, [mapInfo, renderBaiduMap]);
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="sf-metadata-view-map">
|
<div className="sf-metadata-view-map">
|
||||||
@@ -188,9 +173,9 @@ const Main = ({ images, onOpenCluster }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
Main.propTypes = {
|
Map.propTypes = {
|
||||||
images: PropTypes.array,
|
images: PropTypes.array,
|
||||||
onOpenCluster: PropTypes.func,
|
onOpenCluster: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Main;
|
export default Map;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
const customAvatarOverlay = (point, avatarUrl, bgUrl, width = 20, height = 25) => {
|
const customAvatarOverlay = (point, avatarUrl, bgUrl, width = 20, height = 25) => {
|
||||||
class AvatarOverlay extends window.BMap.Overlay {
|
class AvatarOverlay extends window.BMapGL.Overlay {
|
||||||
constructor(point, avatarUrl, bgUrl, width, height) {
|
constructor(point, avatarUrl, bgUrl, width, height) {
|
||||||
super();
|
super();
|
||||||
this._point = point;
|
this._point = point;
|
||||||
|
@@ -5,8 +5,8 @@ const customImageOverlay = (center, image, callback) => {
|
|||||||
constructor(center, image, { callback } = {}) {
|
constructor(center, image, { callback } = {}) {
|
||||||
super(center, '', { styles: [] });
|
super(center, '', { styles: [] });
|
||||||
this._center = center;
|
this._center = center;
|
||||||
this._imageUrl = image.src;
|
this._URL = image.src;
|
||||||
this._imageId = image.id;
|
this._id = image.id;
|
||||||
this._callback = callback;
|
this._callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,11 +18,11 @@ const customImageOverlay = (center, image, callback) => {
|
|||||||
map.getPanes().markerPane.appendChild(div);
|
map.getPanes().markerPane.appendChild(div);
|
||||||
this._div = div;
|
this._div = div;
|
||||||
|
|
||||||
const imageElement = `<img src=${this._imageUrl} />`;
|
const imageElement = `<img src=${this._URL} />`;
|
||||||
const htmlString =
|
const htmlString =
|
||||||
`
|
`
|
||||||
<div class="custom-image-container">
|
<div class="custom-image-container">
|
||||||
${this._imageUrl ? imageElement : '<div class="empty-custom-image-wrapper"></div>'}
|
${this._URL ? imageElement : '<div class="empty-custom-image-wrapper"></div>'}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
const labelDocument = new DOMParser().parseFromString(htmlString, 'text/html');
|
const labelDocument = new DOMParser().parseFromString(htmlString, 'text/html');
|
||||||
@@ -31,7 +31,7 @@ const customImageOverlay = (center, image, callback) => {
|
|||||||
|
|
||||||
const eventHandler = (event) => {
|
const eventHandler = (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this._callback && this._callback(event, [{ _imageId: this._imageId }]);
|
this._callback && this._callback(event, [{ _id: this._id }]);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Utils.isDesktop()) {
|
if (Utils.isDesktop()) {
|
||||||
|
@@ -2141,6 +2141,7 @@ class LibContentView extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
updatePath = (path) => {
|
updatePath = (path) => {
|
||||||
|
if (this.state.path === path) return;
|
||||||
this.setState({ path });
|
this.setState({ path });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -39,16 +39,16 @@ export default function loadBMap(ak) {
|
|||||||
|
|
||||||
export function asyncLoadBaiduJs(ak) {
|
export function asyncLoadBaiduJs(ak) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (typeof window.BMap !== 'undefined') {
|
if (typeof window.BMapGL !== 'undefined') {
|
||||||
resolve(window.BMap);
|
resolve(window.BMapGL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window.renderMap = function () {
|
window.renderMap = function () {
|
||||||
resolve(window.BMap);
|
resolve(window.BMapGL);
|
||||||
};
|
};
|
||||||
let script = document.createElement('script');
|
let script = document.createElement('script');
|
||||||
script.type = 'text/javascript';
|
script.type = 'text/javascript';
|
||||||
script.src = `https://api.map.baidu.com/api?v=3.0&ak=${ak}&callback=renderMap`;
|
script.src = `https://api.map.baidu.com/api?type=webgl&v=1.0&ak=${ak}&callback=renderMap`;
|
||||||
script.onerror = reject;
|
script.onerror = reject;
|
||||||
document.body.appendChild(script);
|
document.body.appendChild(script);
|
||||||
});
|
});
|
||||||
|
@@ -15,11 +15,11 @@ var BMapLib = window.BMapLib = BMapLib || {};
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取一个扩展的视图范围,把上下左右都扩大一样的像素值。
|
* 获取一个扩展的视图范围,把上下左右都扩大一样的像素值。
|
||||||
* @param {Map} map BMap.Map的实例化对象
|
* @param {Map} map BMapGL.Map的实例化对象
|
||||||
* @param {BMap.Bounds} bounds BMap.Bounds的实例化对象
|
* @param {BMapGL.Bounds} bounds BMapGL.Bounds的实例化对象
|
||||||
* @param {Number} gridSize 要扩大的像素值
|
* @param {Number} gridSize 要扩大的像素值
|
||||||
*
|
*
|
||||||
* @return {BMap.Bounds} 返回扩大后的视图范围。
|
* @return {BMapGL.Bounds} 返回扩大后的视图范围。
|
||||||
*/
|
*/
|
||||||
var getExtendedBounds = function(map, bounds, gridSize){
|
var getExtendedBounds = function(map, bounds, gridSize){
|
||||||
bounds = cutBoundsInRange(bounds);
|
bounds = cutBoundsInRange(bounds);
|
||||||
@@ -31,21 +31,22 @@ var BMapLib = window.BMapLib = BMapLib || {};
|
|||||||
pixelSW.y += gridSize;
|
pixelSW.y += gridSize;
|
||||||
var newNE = map.pixelToPoint(pixelNE);
|
var newNE = map.pixelToPoint(pixelNE);
|
||||||
var newSW = map.pixelToPoint(pixelSW);
|
var newSW = map.pixelToPoint(pixelSW);
|
||||||
return new BMap.Bounds(newSW, newNE);
|
return new BMapGL.Bounds(newSW, newNE);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按照百度地图支持的世界范围对bounds进行边界处理
|
* 按照百度地图支持的世界范围对bounds进行边界处理
|
||||||
* @param {BMap.Bounds} bounds BMap.Bounds的实例化对象
|
* @param {BMapGL.Bounds} bounds BMapGL.Bounds的实例化对象
|
||||||
*
|
*
|
||||||
* @return {BMap.Bounds} 返回不越界的视图范围
|
* @return {BMapGL.Bounds} 返回不越界的视图范围
|
||||||
*/
|
*/
|
||||||
var cutBoundsInRange = function (bounds) {
|
var cutBoundsInRange = function (bounds) {
|
||||||
|
console.log(bounds);
|
||||||
var maxX = getRange(bounds.getNorthEast().lng, -180, 180);
|
var maxX = getRange(bounds.getNorthEast().lng, -180, 180);
|
||||||
var minX = getRange(bounds.getSouthWest().lng, -180, 180);
|
var minX = getRange(bounds.getSouthWest().lng, -180, 180);
|
||||||
var maxY = getRange(bounds.getNorthEast().lat, -74, 74);
|
var maxY = getRange(bounds.getNorthEast().lat, -90, 90);
|
||||||
var minY = getRange(bounds.getSouthWest().lat, -74, 74);
|
var minY = getRange(bounds.getSouthWest().lat, -90, 90);
|
||||||
return new BMap.Bounds(new BMap.Point(minX, minY), new BMap.Point(maxX, maxY));
|
return new BMapGL.Bounds(new BMapGL.Point(minX, minY), new BMapGL.Point(maxX, maxY));
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,9 +138,9 @@ var BMapLib = window.BMapLib = BMapLib || {};
|
|||||||
that._redraw();
|
that._redraw();
|
||||||
});
|
});
|
||||||
|
|
||||||
// this._map.addEventListener("moveend",function(){
|
this._map.addEventListener("moveend",function(){
|
||||||
// that._redraw();
|
that._redraw();
|
||||||
// });
|
});
|
||||||
|
|
||||||
var mkrs = opts["markers"];
|
var mkrs = opts["markers"];
|
||||||
isArray(mkrs) && this.addMarkers(mkrs);
|
isArray(mkrs) && this.addMarkers(mkrs);
|
||||||
@@ -160,7 +161,7 @@ var BMapLib = window.BMapLib = BMapLib || {};
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 把一个标记添加到要聚合的标记数组中
|
* 把一个标记添加到要聚合的标记数组中
|
||||||
* @param {BMap.Marker} marker 要添加的标记
|
* @param {BMapGL.Marker} marker 要添加的标记
|
||||||
*
|
*
|
||||||
* @return 无返回值。
|
* @return 无返回值。
|
||||||
*/
|
*/
|
||||||
@@ -174,7 +175,7 @@ var BMapLib = window.BMapLib = BMapLib || {};
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加一个聚合的标记。
|
* 添加一个聚合的标记。
|
||||||
* @param {BMap.Marker} marker 要聚合的单个标记。
|
* @param {BMapGL.Marker} marker 要聚合的单个标记。
|
||||||
* @return 无返回值。
|
* @return 无返回值。
|
||||||
*/
|
*/
|
||||||
MarkerCluster.prototype.addMarker = function(marker) {
|
MarkerCluster.prototype.addMarker = function(marker) {
|
||||||
@@ -190,7 +191,7 @@ var BMapLib = window.BMapLib = BMapLib || {};
|
|||||||
var mapBounds = this._map.getBounds();
|
var mapBounds = this._map.getBounds();
|
||||||
var extendedBounds = getExtendedBounds(this._map, mapBounds, this._gridSize);
|
var extendedBounds = getExtendedBounds(this._map, mapBounds, this._gridSize);
|
||||||
for(var i = 0, marker; marker = this._markers[i]; i++){
|
for(var i = 0, marker; marker = this._markers[i]; i++){
|
||||||
if(!marker.isInCluster && extendedBounds.containsPoint(marker.getPosition()) ){
|
if(!marker.isInCluster && extendedBounds.containsPoint(marker._position) ){
|
||||||
this._addToClosestCluster(marker);
|
this._addToClosestCluster(marker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,7 +206,7 @@ var BMapLib = window.BMapLib = BMapLib || {};
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据标记的位置,把它添加到最近的聚合中
|
* 根据标记的位置,把它添加到最近的聚合中
|
||||||
* @param {BMap.Marker} marker 要进行聚合的单个标记
|
* @param {BMapGL.Marker} marker 要进行聚合的单个标记
|
||||||
*
|
*
|
||||||
* @return 无返回值。
|
* @return 无返回值。
|
||||||
*/
|
*/
|
||||||
@@ -268,7 +269,7 @@ var BMapLib = window.BMapLib = BMapLib || {};
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除单个标记
|
* 删除单个标记
|
||||||
* @param {BMap.Marker} marker 需要被删除的marker
|
* @param {BMapGL.Marker} marker 需要被删除的marker
|
||||||
*
|
*
|
||||||
* @return {Boolean} 删除成功返回true,否则返回false
|
* @return {Boolean} 删除成功返回true,否则返回false
|
||||||
*/
|
*/
|
||||||
@@ -284,7 +285,7 @@ var BMapLib = window.BMapLib = BMapLib || {};
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除单个标记
|
* 删除单个标记
|
||||||
* @param {BMap.Marker} marker 需要被删除的marker
|
* @param {BMapGL.Marker} marker 需要被删除的marker
|
||||||
*
|
*
|
||||||
* @return {Boolean} 删除成功返回true,否则返回false
|
* @return {Boolean} 删除成功返回true,否则返回false
|
||||||
*/
|
*/
|
||||||
@@ -299,7 +300,7 @@ var BMapLib = window.BMapLib = BMapLib || {};
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除一组标记
|
* 删除一组标记
|
||||||
* @param {Array<BMap.Marker>} markers 需要被删除的marker数组
|
* @param {Array<BMapGL.Marker>} markers 需要被删除的marker数组
|
||||||
*
|
*
|
||||||
* @return {Boolean} 删除成功返回true,否则返回false
|
* @return {Boolean} 删除成功返回true,否则返回false
|
||||||
*/
|
*/
|
||||||
@@ -487,7 +488,7 @@ var BMapLib = window.BMapLib = BMapLib || {};
|
|||||||
var l = this._markers.length + 1;
|
var l = this._markers.length + 1;
|
||||||
var lat = (this._center.lat * (l - 1) + marker.getPosition().lat) / l;
|
var lat = (this._center.lat * (l - 1) + marker.getPosition().lat) / l;
|
||||||
var lng = (this._center.lng * (l - 1) + marker.getPosition().lng) / l;
|
var lng = (this._center.lng * (l - 1) + marker.getPosition().lng) / l;
|
||||||
this._center = new BMap.Point(lng, lat);
|
this._center = new BMapGL.Point(lng, lat);
|
||||||
this.updateGridBounds();
|
this.updateGridBounds();
|
||||||
}//计算新的Center
|
}//计算新的Center
|
||||||
}
|
}
|
||||||
@@ -550,7 +551,7 @@ var BMapLib = window.BMapLib = BMapLib || {};
|
|||||||
* @return 无返回值。
|
* @return 无返回值。
|
||||||
*/
|
*/
|
||||||
Cluster.prototype.updateGridBounds = function() {
|
Cluster.prototype.updateGridBounds = function() {
|
||||||
var bounds = new BMap.Bounds(this._center, this._center);
|
var bounds = new BMapGL.Bounds(this._center, this._center);
|
||||||
this._gridBounds = getExtendedBounds(this._map, bounds, this._markerClusterer.getGridSize());
|
this._gridBounds = getExtendedBounds(this._map, bounds, this._markerClusterer.getGridSize());
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -620,10 +621,10 @@ var BMapLib = window.BMapLib = BMapLib || {};
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取该聚合所包含的所有标记的最小外接矩形的范围。
|
* 获取该聚合所包含的所有标记的最小外接矩形的范围。
|
||||||
* @return {BMap.Bounds} 计算出的范围。
|
* @return {BMapGL.Bounds} 计算出的范围。
|
||||||
*/
|
*/
|
||||||
Cluster.prototype.getBounds = function() {
|
Cluster.prototype.getBounds = function() {
|
||||||
var bounds = new BMap.Bounds(this._center,this._center);
|
var bounds = new BMapGL.Bounds(this._center,this._center);
|
||||||
for (var i = 0, marker; marker = this._markers[i]; i++) {
|
for (var i = 0, marker; marker = this._markers[i]; i++) {
|
||||||
bounds.extend(marker.getPosition());
|
bounds.extend(marker.getPosition());
|
||||||
}
|
}
|
||||||
@@ -632,7 +633,7 @@ var BMapLib = window.BMapLib = BMapLib || {};
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取该聚合的落脚点。
|
* 获取该聚合的落脚点。
|
||||||
* @return {BMap.Point} 该聚合的落脚点。
|
* @return {BMapGL.Point} 该聚合的落脚点。
|
||||||
*/
|
*/
|
||||||
Cluster.prototype.getCenter = function() {
|
Cluster.prototype.getCenter = function() {
|
||||||
return this._center;
|
return this._center;
|
||||||
|
@@ -754,21 +754,21 @@ var BMapLib = window.BMapLib = BMapLib || {};
|
|||||||
(!this._styles.length) && this._setupDefaultStyles();
|
(!this._styles.length) && this._setupDefaultStyles();
|
||||||
};
|
};
|
||||||
|
|
||||||
T.lang.inherits(TextIconOverlay, BMap.Overlay, "TextIconOverlay");
|
T.lang.inherits(TextIconOverlay, BMapGL.Overlay, "TextIconOverlay");
|
||||||
|
|
||||||
TextIconOverlay.prototype._setupDefaultStyles = function(){
|
TextIconOverlay.prototype._setupDefaultStyles = function(){
|
||||||
var sizes = [53, 56, 66, 78, 90];
|
var sizes = [53, 56, 66, 78, 90];
|
||||||
for(var i = 0, size; size = sizes[i]; i++){
|
for(var i = 0, size; size = sizes[i]; i++){
|
||||||
this._styles.push({
|
this._styles.push({
|
||||||
url:_IMAGE_PATH + i + '.' + _IMAGE_EXTENSION,
|
url:_IMAGE_PATH + i + '.' + _IMAGE_EXTENSION,
|
||||||
size: new BMap.Size(size, size)
|
size: new BMapGL.Size(size, size)
|
||||||
});
|
});
|
||||||
}//for循环的简洁写法
|
}//for循环的简洁写法
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*继承Overlay的intialize方法,自定义覆盖物时必须。
|
*继承Overlay的intialize方法,自定义覆盖物时必须。
|
||||||
*@param {Map} map BMap.Map的实例化对象。
|
*@param {Map} map BMapGL.Map的实例化对象。
|
||||||
*@return {HTMLElement} 返回覆盖物对应的HTML元素。
|
*@return {HTMLElement} 返回覆盖物对应的HTML元素。
|
||||||
*/
|
*/
|
||||||
TextIconOverlay.prototype.initialize = function(map){
|
TextIconOverlay.prototype.initialize = function(map){
|
||||||
@@ -944,12 +944,12 @@ var BMapLib = window.BMapLib = BMapLib || {};
|
|||||||
} else {
|
} else {
|
||||||
csstext.push('background-image:url(' + url + ');');
|
csstext.push('background-image:url(' + url + ');');
|
||||||
var backgroundPosition = '0 0';
|
var backgroundPosition = '0 0';
|
||||||
(offset instanceof BMap.Size) && (backgroundPosition = offset.width + 'px' + ' ' + offset.height + 'px');
|
(offset instanceof BMapGL.Size) && (backgroundPosition = offset.width + 'px' + ' ' + offset.height + 'px');
|
||||||
csstext.push('background-position:' + backgroundPosition + ';');
|
csstext.push('background-position:' + backgroundPosition + ';');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size instanceof BMap.Size){
|
if (size instanceof BMapGL.Size){
|
||||||
if (anchor instanceof BMap.Size) {
|
if (anchor instanceof BMapGL.Size) {
|
||||||
if (anchor.height > 0 && anchor.height < size.height) {
|
if (anchor.height > 0 && anchor.height < size.height) {
|
||||||
csstext.push('height:' + (size.height - anchor.height) + 'px; padding-top:' + anchor.height + 'px;');
|
csstext.push('height:' + (size.height - anchor.height) + 'px; padding-top:' + anchor.height + 'px;');
|
||||||
}
|
}
|
||||||
@@ -999,9 +999,9 @@ var BMapLib = window.BMapLib = BMapLib || {};
|
|||||||
|
|
||||||
* <br />"<b>target</b>:{BMapLib.TextIconOverlay} 事件目标
|
* <br />"<b>target</b>:{BMapLib.TextIconOverlay} 事件目标
|
||||||
|
|
||||||
* <br />"<b>point</b> : {BMap.Point} 最新添加上的节点BMap.Point对象
|
* <br />"<b>point</b> : {BMapGL.Point} 最新添加上的节点BMap.Point对象
|
||||||
|
|
||||||
* <br />"<b>pixel</b>:{BMap.pixel} 最新添加上的节点BMap.Pixel对象
|
* <br />"<b>pixel</b>:{BMapGL.pixel} 最新添加上的节点BMap.Pixel对象
|
||||||
|
|
||||||
*
|
*
|
||||||
|
|
||||||
@@ -1025,9 +1025,9 @@ var BMapLib = window.BMapLib = BMapLib || {};
|
|||||||
|
|
||||||
* <br />"<b>target</b>:{BMapLib.TextIconOverlay} 事件目标
|
* <br />"<b>target</b>:{BMapLib.TextIconOverlay} 事件目标
|
||||||
|
|
||||||
* <br />"<b>point</b> : {BMap.Point} 最新添加上的节点BMap.Point对象
|
* <br />"<b>point</b> : {BMapGL.Point} 最新添加上的节点BMap.Point对象
|
||||||
|
|
||||||
* <br />"<b>pixel</b>:{BMap.pixel} 最新添加上的节点BMap.Pixel对象
|
* <br />"<b>pixel</b>:{BMapGL.pixel} 最新添加上的节点BMap.Pixel对象
|
||||||
|
|
||||||
*
|
*
|
||||||
|
|
||||||
@@ -1058,7 +1058,7 @@ var BMapLib = window.BMapLib = BMapLib || {};
|
|||||||
var y = e.clientY || e.pageY;
|
var y = e.clientY || e.pageY;
|
||||||
if (e && be && x && y && elem){
|
if (e && be && x && y && elem){
|
||||||
var offset = T.dom.getPosition(map.getContainer());
|
var offset = T.dom.getPosition(map.getContainer());
|
||||||
be.pixel = new BMap.Pixel(x - offset.left, y - offset.top);
|
be.pixel = new BMapGL.Pixel(x - offset.left, y - offset.top);
|
||||||
be.point = map.pixelToPoint(be.pixel);
|
be.point = map.pixelToPoint(be.pixel);
|
||||||
}
|
}
|
||||||
return be;
|
return be;
|
||||||
|
Reference in New Issue
Block a user