JSFiddle - React, Tailwind, and code Playground

by rzkhosroshahi

HTML

<p>من اینجام 🇮🇷</p>

JavaScript

if (!navigator.geolocation) {
    // geolocation is not supported
    alert("مرورگر شما از این قابلیت پشتیبانی نمیکنه:(");
  } 

  // geolocation is available
  function success(position) {

    var latitude  = position.coords.latitude;
    var longitude = position.coords.longitude;
     
    var img = new Image();
    img.src = "https://maps.googleapis.com/maps/api/staticmap?center=" + latitude + "," + longitude + "&zoom=13&size=300x300&sensor=false";
    
    document.body.appendChild(img);

  }

  function error(){
    alert("نمیتونم اطلاعات مورد نیازم رو دریافت کنم :(");
  }



  navigator.geolocation.getCurrentPosition(success,error);