|
@@ -238,6 +238,82 @@ const setpoint = (longitude, latitude, name) => {
|
|
|
isshowmove.value = false;
|
|
|
};
|
|
|
|
|
|
+ const dores = (data) => {
|
|
|
+ // console.log(data.pois)
|
|
|
+ var clearallmark = () => {
|
|
|
+ if (state.map && state._marker) {
|
|
|
+ state._marker.remove();
|
|
|
+ }
|
|
|
+ if (allmark.length > 0) {
|
|
|
+ allmark.map((item) => {
|
|
|
+ item.remove();
|
|
|
+ });
|
|
|
+ allmark = [];
|
|
|
+ }
|
|
|
+ };
|
|
|
+ clearallmark();
|
|
|
+ var top = [];
|
|
|
+ var bottom = [];
|
|
|
+ data.pois.map((item) => {
|
|
|
+ if (top.length < 1) {
|
|
|
+ top = [
|
|
|
+ Number(item.location.split(',')[0]),
|
|
|
+ Number(item.location.split(',')[1]),
|
|
|
+ ];
|
|
|
+ bottom = [
|
|
|
+ Number(item.location.split(',')[0]),
|
|
|
+ Number(item.location.split(',')[1]),
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ var el = document.createElement('div');
|
|
|
+ el.id = 'marker';
|
|
|
+ el.style.backgroundImage = `url(${icon_map_location})`;
|
|
|
+ el.style.backgroundSize = 'cover';
|
|
|
+ el.style.width = '24px';
|
|
|
+ el.style.height = '24px';
|
|
|
+ el.style.borderRadius = '50%';
|
|
|
+ el.onclick = () => {
|
|
|
+ clearallmark();
|
|
|
+ setpoint(
|
|
|
+ Number(item.location.split(',')[0]),
|
|
|
+ Number(item.location.split(',')[1]),
|
|
|
+ item.name,
|
|
|
+ );
|
|
|
+ };
|
|
|
+
|
|
|
+ const popup = new window.minemap.Popup({
|
|
|
+ closeOnClick: false,
|
|
|
+ closeButton: false,
|
|
|
+ offset: [0, -15],
|
|
|
+ }).setText(item.name);
|
|
|
+
|
|
|
+ var mark = new window.minemap.Marker(el, {
|
|
|
+ offset: [-12, -12],
|
|
|
+ })
|
|
|
+ .setLngLat([
|
|
|
+ Number(item.location.split(',')[0]),
|
|
|
+ Number(item.location.split(',')[1]),
|
|
|
+ ])
|
|
|
+ .setPopup(popup)
|
|
|
+ .addTo(state.map);
|
|
|
+ allmark.push(mark);
|
|
|
+ mark.togglePopup();
|
|
|
+ if (top[0] < Number(item.location.split(',')[0])) {
|
|
|
+ top[0] = Number(item.location.split(',')[0]);
|
|
|
+ }
|
|
|
+ if (top[1] > Number(item.location.split(',')[1])) {
|
|
|
+ top[1] = Number(item.location.split(',')[1]);
|
|
|
+ }
|
|
|
+ if (bottom[0] > Number(item.location.split(',')[0])) {
|
|
|
+ bottom[0] = Number(item.location.split(',')[0]);
|
|
|
+ }
|
|
|
+ if (bottom[1] < Number(item.location.split(',')[1])) {
|
|
|
+ bottom[1] = Number(item.location.split(',')[1]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ state.map.fitBounds([top, bottom]);
|
|
|
+ }
|
|
|
+
|
|
|
const searchaddr = () => {
|
|
|
isshowmove.value = false;
|
|
|
fetch(
|
|
@@ -245,93 +321,23 @@ const searchaddr = () => {
|
|
|
)
|
|
|
.then((res) => res.json())
|
|
|
.then((data) => {
|
|
|
- // console.log(data.pois)
|
|
|
- var clearallmark = () => {
|
|
|
- if (state.map && state._marker) {
|
|
|
- state._marker.remove();
|
|
|
- }
|
|
|
- if (allmark.length > 0) {
|
|
|
- allmark.map((item) => {
|
|
|
- item.remove();
|
|
|
- });
|
|
|
- allmark = [];
|
|
|
- }
|
|
|
- };
|
|
|
- clearallmark();
|
|
|
- var top = [];
|
|
|
- var bottom = [];
|
|
|
- data.pois.map((item) => {
|
|
|
- if (top.length < 1) {
|
|
|
- top = [
|
|
|
- Number(item.location.split(',')[0]),
|
|
|
- Number(item.location.split(',')[1]),
|
|
|
- ];
|
|
|
- bottom = [
|
|
|
- Number(item.location.split(',')[0]),
|
|
|
- Number(item.location.split(',')[1]),
|
|
|
- ];
|
|
|
- }
|
|
|
- var el = document.createElement('div');
|
|
|
- el.id = 'marker';
|
|
|
- el.style.backgroundImage = `url(${icon_map_location})`;
|
|
|
- el.style.backgroundSize = 'cover';
|
|
|
- el.style.width = '24px';
|
|
|
- el.style.height = '24px';
|
|
|
- el.style.borderRadius = '50%';
|
|
|
- el.onclick = () => {
|
|
|
- clearallmark();
|
|
|
- setpoint(
|
|
|
- Number(item.location.split(',')[0]),
|
|
|
- Number(item.location.split(',')[1]),
|
|
|
- item.name,
|
|
|
- );
|
|
|
- };
|
|
|
-
|
|
|
- const popup = new window.minemap.Popup({
|
|
|
- closeOnClick: false,
|
|
|
- closeButton: false,
|
|
|
- offset: [0, -15],
|
|
|
- }).setText(item.name);
|
|
|
-
|
|
|
- var mark = new window.minemap.Marker(el, {
|
|
|
- offset: [-12, -12],
|
|
|
- })
|
|
|
- .setLngLat([
|
|
|
- Number(item.location.split(',')[0]),
|
|
|
- Number(item.location.split(',')[1]),
|
|
|
- ])
|
|
|
- .setPopup(popup)
|
|
|
- .addTo(state.map);
|
|
|
- allmark.push(mark);
|
|
|
- mark.togglePopup();
|
|
|
- if (top[0] < Number(item.location.split(',')[0])) {
|
|
|
- top[0] = Number(item.location.split(',')[0]);
|
|
|
- }
|
|
|
- if (top[1] > Number(item.location.split(',')[1])) {
|
|
|
- top[1] = Number(item.location.split(',')[1]);
|
|
|
- }
|
|
|
- if (bottom[0] > Number(item.location.split(',')[0])) {
|
|
|
- bottom[0] = Number(item.location.split(',')[0]);
|
|
|
- }
|
|
|
- if (bottom[1] < Number(item.location.split(',')[1])) {
|
|
|
- bottom[1] = Number(item.location.split(',')[1]);
|
|
|
- }
|
|
|
- });
|
|
|
- state.map.fitBounds([top, bottom]);
|
|
|
+ dores(data);
|
|
|
});
|
|
|
};
|
|
|
|
|
|
const getlocalname = (location) => {
|
|
|
fetch(
|
|
|
- `https://service.minedata.cn/service/lbs/reverse/v1/regeo?location=${location}&key=77ef70465c2d4888b3a5132523494b94`,
|
|
|
+ // `https://service.minedata.cn/service/lbs/reverse/v1/regeo?location=${location}&key=77ef70465c2d4888b3a5132523494b94`,
|
|
|
+ `https://tocc.jtj.suqian.gov.cn:21100/service/lbs/search/v1/around?location=${location}&key=${window.key}`,
|
|
|
)
|
|
|
.then((res) => res.json())
|
|
|
.then((data) => {
|
|
|
- setpoint(
|
|
|
- Number(location.split(',')[0]),
|
|
|
- Number(location.split(',')[1]),
|
|
|
- data.regeocodes[0].formatted_address,
|
|
|
- );
|
|
|
+ dores(data);
|
|
|
+ // setpoint(
|
|
|
+ // Number(location.split(',')[0]),
|
|
|
+ // Number(location.split(',')[1]),
|
|
|
+ // data.regeocodes[0].formatted_address,
|
|
|
+ // );
|
|
|
});
|
|
|
};
|
|
|
const getLocation = () => {
|