|
|
@@ -51,6 +51,22 @@ export function useGMapCover() {
|
|
|
icon: getPinIcon(color),
|
|
|
extData: data
|
|
|
})
|
|
|
+ const text = new AMap.Text({
|
|
|
+ position: new AMap.LngLat(coordinates[0], coordinates[1]),
|
|
|
+ offset: new AMap.Pixel(-30, -30),
|
|
|
+ text: name,
|
|
|
+ style: {
|
|
|
+ fontSize: 12,
|
|
|
+ padding: 0,
|
|
|
+ backgroundColor: 'transparent',
|
|
|
+ borderColor: 'transparent',
|
|
|
+ },
|
|
|
+ extData: {
|
|
|
+ ...data,
|
|
|
+ id: data.id + '_text',
|
|
|
+ },
|
|
|
+ })
|
|
|
+ AddCoverToMap(text)
|
|
|
marker.on('click', function (e: any) {
|
|
|
const options = marker.getOptions()
|
|
|
const id = options.extData.id;
|
|
|
@@ -72,6 +88,23 @@ export function useGMapCover() {
|
|
|
strokeStyle: 'solid',
|
|
|
extData: data
|
|
|
})
|
|
|
+ const coordinatesList = coordinates[0];
|
|
|
+ const text = new AMap.Text({
|
|
|
+ position: new AMap.LngLat(coordinatesList[0], coordinatesList[1]),
|
|
|
+ offset: new AMap.Pixel(-30, -30),
|
|
|
+ text: name,
|
|
|
+ style: {
|
|
|
+ fontSize: 12,
|
|
|
+ padding: 0,
|
|
|
+ backgroundColor: 'transparent',
|
|
|
+ borderColor: 'transparent',
|
|
|
+ },
|
|
|
+ extData: {
|
|
|
+ ...data,
|
|
|
+ id: data.id + '_text',
|
|
|
+ },
|
|
|
+ })
|
|
|
+ AddCoverToMap(text)
|
|
|
polyline.on('click', function () {
|
|
|
const options = polyline.getOptions()
|
|
|
const id = options.extData.id;
|
|
|
@@ -94,6 +127,23 @@ export function useGMapCover() {
|
|
|
strokeColor: color || normalColor,
|
|
|
extData: data
|
|
|
})
|
|
|
+ const coordinatesList = coordinates[0][0];
|
|
|
+ const text = new AMap.Text({
|
|
|
+ position: new AMap.LngLat(coordinatesList[0], coordinatesList[1]),
|
|
|
+ offset: new AMap.Pixel(-30, -30),
|
|
|
+ text: name,
|
|
|
+ style: {
|
|
|
+ fontSize: 12,
|
|
|
+ padding: 0,
|
|
|
+ backgroundColor: 'transparent',
|
|
|
+ borderColor: 'transparent',
|
|
|
+ },
|
|
|
+ extData: {
|
|
|
+ ...data,
|
|
|
+ id: data.id + '_text',
|
|
|
+ },
|
|
|
+ })
|
|
|
+ AddCoverToMap(text)
|
|
|
polygon.on('click', function () {
|
|
|
const options = polygon.getOptions()
|
|
|
const id = options.extData.id;
|
|
|
@@ -119,12 +169,14 @@ export function useGMapCover() {
|
|
|
|
|
|
function updatePinElement(id: string, name: string, coordinates: GeojsonCoordinate, color?: string) {
|
|
|
const elements = getElementFromMap(id)
|
|
|
+ const textElements = getElementFromMap(id + '_text')
|
|
|
if (elements && elements.length > 0) {
|
|
|
const element = elements[0]
|
|
|
const icon = getPinIcon(color)
|
|
|
element.setPosition(new AMap.LngLat(coordinates[0], coordinates[1]))
|
|
|
element.setIcon(icon)
|
|
|
element.setTitle(name)
|
|
|
+ textElements[0].setText(name)
|
|
|
} else {
|
|
|
init2DPin(name, coordinates, color, {
|
|
|
id: id,
|
|
|
@@ -135,11 +187,13 @@ export function useGMapCover() {
|
|
|
|
|
|
function updatePolylineElement(id: string, name: string, coordinates: GeojsonCoordinate[], color?: string) {
|
|
|
const elements = getElementFromMap(id)
|
|
|
+ const textElements = getElementFromMap(id + '_text')
|
|
|
if (elements && elements.length > 0) {
|
|
|
const element = elements[0]
|
|
|
const options = element.getOptions()
|
|
|
options.strokeColor = color || normalColor
|
|
|
element.setOptions(options)
|
|
|
+ textElements[0].setText(name)
|
|
|
} else {
|
|
|
initPolyline(name, coordinates, color, {
|
|
|
id: id,
|
|
|
@@ -150,12 +204,14 @@ export function useGMapCover() {
|
|
|
|
|
|
function updatePolygonElement(id: string, name: string, coordinates: GeojsonCoordinate[][], color?: string) {
|
|
|
const elements = getElementFromMap(id)
|
|
|
+ const textElements = getElementFromMap(id + '_text')
|
|
|
if (elements && elements.length > 0) {
|
|
|
const element = elements[0]
|
|
|
const options = element.getOptions()
|
|
|
options.fillColor = color || normalColor
|
|
|
options.strokeColor = color || normalColor
|
|
|
element.setOptions(options)
|
|
|
+ textElements[0].setText(name)
|
|
|
} else {
|
|
|
initPolygon(name, coordinates, color, {
|
|
|
id: id,
|