How can I get only the latitude and longitude of the return from this function (location)?

0
<script type="text/javascript" src="//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js"></script>

<script type="text/javascript">

var onSuccess = function(location){

  var x = JSON.stringify(location, undefined, 3);
  document.write(x);
  return x;
};


var onError = function(error){
  alert(
      "Error:\n\n"
      + JSON.stringify(error, undefined, 3)
  );
};

geoip2.city(onSuccess, onError);


</script>
    
asked by anonymous 27.03.2017 / 20:55

1 answer

0

Try this:

function showPosition (position) {    return position.coords.latitude + "," + position.coords.longitude; }

    
27.03.2017 / 21:01