روز برنامه‌نویس مبارک 🤩🎉 از هدایای روز برنامه‌نویس جا نمونی ⌛
۰ ثانیه
۰ دقیقه
۰ ساعت
۱ کیان سلگی
مشکل در دریافت لوکیشن
لقمان آوند حل شده توسط لقمان آوند

سلام استاد وقتتون بخیر

در مورد دریافت لوکیشن مشکل داشتم که پیام Geolocation error: Only secure origins are allowed (see: https://goo.gl/Y0ZkNV).. رو دریافت میکنم

با فیلترشکن هم زمانی که وصل میشم لوکال هاست اجرا نمیشه و از دی ان اس تحریم شکن هم استفاده کردم باز نشد

ممنون میشم راهنمایی کنید .

document.getElementById('map').style.setProperty('height', +innerHeight + 'px');
    const DefaultLocation = [35.6950509, 51.3816031];
   var map = new L.Map('map', {
        key: 'my api in neshan',
        maptype: 'standard-night',
        poi: true,
        traffic: false,
        center: DefaultLocation,
        zoom: 14
    });
    var marker = L.marker(DefaultLocation).addTo(map);
    marker.bindPopup('default location').openPopup();
    /////
    function onLocationFound(e) {
        var radius = e.accuracy / 2;
        L.marker(e.latlng).addTo(map)
            .bindPopup("You are within " + radius + " meters from this point").openPopup();
        L.circle(e.latlng, radius).addTo(map);
    }
    function onLocationError(e) {
        alert(e.message);
    }
    map.on('locationfound', onLocationFound);
    map.on('locationerror', onLocationError);
    map.locate({
        setView: true,
        maxZoom: 16
    });

سلام

تو متن ارور گفته که فقط از آدرس هایی می‌تونی درخواست لوکیشن بدی که امن یا همون https باشه

با پروتکل https صفحه رو باز کن و تست کن مجدد

ممکنه لازم باشه یه Ssl لوکال تو زمپ نصب کنی

سرچ کن در این مورد و انجام بده

بهترین پاسخ
لقمان آوند ۱۸ آذر ۱۴۰۰، ۱۵:۱۳