|
@@ -184,8 +184,8 @@ export default {
|
|
|
layers: [
|
|
layers: [
|
|
|
new TileLayer({
|
|
new TileLayer({
|
|
|
source: new XYZ({
|
|
source: new XYZ({
|
|
|
- url: "http://127.0.0.1:8010/tiles/{z}/{x}/{y}.png", //本地
|
|
|
|
|
- // url: "http://192.168.50.235/tiles/{z}/{x}/{y}.png", //内网
|
|
|
|
|
|
|
+ // url: "http://127.0.0.1:8010/tiles/{z}/{x}/{y}.png", //本地
|
|
|
|
|
+ url: "http://192.168.50.235/tiles/{z}/{x}/{y}.png", //内网
|
|
|
// url: "http://106.120.102.238:18000/tiles/{z}/{x}/{y}.png", //外网
|
|
// url: "http://106.120.102.238:18000/tiles/{z}/{x}/{y}.png", //外网
|
|
|
}),
|
|
}),
|
|
|
}),
|
|
}),
|
|
@@ -274,65 +274,67 @@ export default {
|
|
|
/**
|
|
/**
|
|
|
* 初始化地图事件
|
|
* 初始化地图事件
|
|
|
*/
|
|
*/
|
|
|
- initEvent() {
|
|
|
|
|
- this.map.on("pointermove", (evt) => {
|
|
|
|
|
- const features = this.map.getFeaturesAtPixel(evt.pixel, {
|
|
|
|
|
- hitTolerance: 1,
|
|
|
|
|
- });
|
|
|
|
|
- if (features && features.length > 0) {
|
|
|
|
|
- const feature = features.at(0);
|
|
|
|
|
- const val = feature.get("data").val;
|
|
|
|
|
- if (val == "1") {
|
|
|
|
|
- this.hoverInfo = feature.get("data");
|
|
|
|
|
- this.hoverStyle.left = `${evt.pixel[0] + 10}px`;
|
|
|
|
|
- this.hoverStyle.top = `${evt.pixel[1] - 150}px`;
|
|
|
|
|
- } else if (val == "4") {
|
|
|
|
|
- this.hoverfengji = feature.get("data");
|
|
|
|
|
- this.hoverfengjiStyle.left = `${evt.pixel[0] + 10}px`;
|
|
|
|
|
- this.hoverfengjiStyle.top = `${evt.pixel[1] - 150}px`;
|
|
|
|
|
- this.currentFeatureData = feature.get("data");
|
|
|
|
|
- } else if (val == "5") {
|
|
|
|
|
- this.hoverta = feature.get("data");
|
|
|
|
|
- this.hovertaStyle.left = `${evt.pixel[0] + 10}px`;
|
|
|
|
|
- this.hovertaStyle.top = `${evt.pixel[1] - 150}px`;
|
|
|
|
|
- this.currentFeatureData = feature.get("data");
|
|
|
|
|
- } else if (val == "6") {
|
|
|
|
|
- this.currentFeatureData = feature.get("data");
|
|
|
|
|
- } else {
|
|
|
|
|
- this.hoverInfo = null;
|
|
|
|
|
- this.hoverfengji = false;
|
|
|
|
|
- this.hoverta = false;
|
|
|
|
|
- this.currentFeatureData = null;
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- this.hoverInfo = null;
|
|
|
|
|
- this.hoverfengji = false;
|
|
|
|
|
- this.hoverta = false;
|
|
|
|
|
- this.currentFeatureData = null;
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- this.map.on("click", (evt) => {
|
|
|
|
|
- const features = this.map.getFeaturesAtPixel(evt.pixel, {
|
|
|
|
|
- hitTolerance: 1,
|
|
|
|
|
- });
|
|
|
|
|
- if (features && features.length > 0) {
|
|
|
|
|
- const feature = features.at(0);
|
|
|
|
|
- const val = feature.get("data").val;
|
|
|
|
|
- if (val === "6") {
|
|
|
|
|
- this.handleFeatureClick(feature.get("data"));
|
|
|
|
|
- } else {
|
|
|
|
|
- this.$emit("feature-click", feature.get("data"));
|
|
|
|
|
- }
|
|
|
|
|
- } else if (this.currentFeatureData && this.currentFeatureData.val === "6") {
|
|
|
|
|
- this.handleFeatureClick(this.currentFeatureData);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
-},
|
|
|
|
|
-handleFeatureClick(featureData) {
|
|
|
|
|
-alert('555555')
|
|
|
|
|
-},
|
|
|
|
|
|
|
+ initEvent() {
|
|
|
|
|
+ this.map.on("pointermove", (evt) => {
|
|
|
|
|
+ const features = this.map.getFeaturesAtPixel(evt.pixel, {
|
|
|
|
|
+ hitTolerance: 1,
|
|
|
|
|
+ });
|
|
|
|
|
+ if (features && features.length > 0) {
|
|
|
|
|
+ const feature = features.at(0);
|
|
|
|
|
+ const val = feature.get("data").val;
|
|
|
|
|
+ if (val == "1") {
|
|
|
|
|
+ this.hoverInfo = feature.get("data");
|
|
|
|
|
+ this.hoverStyle.left = `${evt.pixel[0] + 10}px`;
|
|
|
|
|
+ this.hoverStyle.top = `${evt.pixel[1] - 150}px`;
|
|
|
|
|
+ } else if (val == "4") {
|
|
|
|
|
+ this.hoverfengji = feature.get("data");
|
|
|
|
|
+ this.hoverfengjiStyle.left = `${evt.pixel[0] + 10}px`;
|
|
|
|
|
+ this.hoverfengjiStyle.top = `${evt.pixel[1] - 150}px`;
|
|
|
|
|
+ this.currentFeatureData = feature.get("data");
|
|
|
|
|
+ } else if (val == "5") {
|
|
|
|
|
+ this.hoverta = feature.get("data");
|
|
|
|
|
+ this.hovertaStyle.left = `${evt.pixel[0] + 10}px`;
|
|
|
|
|
+ this.hovertaStyle.top = `${evt.pixel[1] - 150}px`;
|
|
|
|
|
+ this.currentFeatureData = feature.get("data");
|
|
|
|
|
+ } else if (val == "6") {
|
|
|
|
|
+ this.currentFeatureData = feature.get("data");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.hoverInfo = null;
|
|
|
|
|
+ this.hoverfengji = false;
|
|
|
|
|
+ this.hoverta = false;
|
|
|
|
|
+ this.currentFeatureData = null;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.hoverInfo = null;
|
|
|
|
|
+ this.hoverfengji = false;
|
|
|
|
|
+ this.hoverta = false;
|
|
|
|
|
+ this.currentFeatureData = null;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
|
|
+ this.map.on("click", (evt) => {
|
|
|
|
|
+ const features = this.map.getFeaturesAtPixel(evt.pixel, {
|
|
|
|
|
+ hitTolerance: 1,
|
|
|
|
|
+ });
|
|
|
|
|
+ if (features && features.length > 0) {
|
|
|
|
|
+ const feature = features.at(0);
|
|
|
|
|
+ const val = feature.get("data").val;
|
|
|
|
|
+ if (val === "6") {
|
|
|
|
|
+ this.handleFeatureClick(feature.get("data"));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$emit("feature-click", feature.get("data"));
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (
|
|
|
|
|
+ this.currentFeatureData &&
|
|
|
|
|
+ this.currentFeatureData.val === "6"
|
|
|
|
|
+ ) {
|
|
|
|
|
+ this.handleFeatureClick(this.currentFeatureData);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ handleFeatureClick(featureData) {
|
|
|
|
|
+ alert("555555");
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 平移缩放
|
|
* 平移缩放
|