From 0a577cb3219782873885f7690c3381faffabf115 Mon Sep 17 00:00:00 2001 From: augushong Date: Fri, 18 Apr 2025 09:23:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E4=B8=8D=E6=94=AF=E6=8C=81=E8=8E=B7=E5=8F=96=E5=AE=9A=E4=BD=8D?= =?UTF-8?q?=E6=97=B6=E4=BD=BF=E7=94=A8ip=E5=AE=9A=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/static/plugs/mapLocation/mapLocation.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/public/static/plugs/mapLocation/mapLocation.js b/public/static/plugs/mapLocation/mapLocation.js index fdb7ecd..923ee06 100644 --- a/public/static/plugs/mapLocation/mapLocation.js +++ b/public/static/plugs/mapLocation/mapLocation.js @@ -145,7 +145,15 @@ mapContainer.find('.location-message').text('正在获取定位...').show(); - map.locate(); + if (window.location.protocol === 'http:') { + $.get('//location.tianditu.gov.cn/data/getCityName',function(r){ + mapContainer.find('.location-message').html('您的城市位置:' + r.data.lat + ',' + r.data.lng + '
我的定位
'); + mapContainer.find('.location-me').data('latlng', [r.data.lat,r.data.lng]); + map.flyTo([r.data.lat,r.data.lng], 12); + }) + } else { + map.locate(); + } if (options.locationLatitude && options.locationLongitude && $(options.locationLatitude).val() && $(options.locationLongitude).val()) { var lat = $(options.locationLatitude).val();