0 votes

Get latitude and longitude separately with leaflet

How can I get the latitude and longitude values separately? I'm using:

function onMapClick(click){
 alert("Youclicked the map at " click.latlng);
}

This is what brings me the alert:

You clicked the map at LatLng(49.815933, 21.595358)

0voto

happens that you use the function split(',')

The split function in jQuery is used to divide a text string into several parts according to the delimiter that you indicate.

 var LatLng= "49.815933, 21.595358";
var lati_long=LatLng.split(",");
//var Longitud 
alert(lati_long[0]);
//var latitud
alert(lati_long[1]);
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

HolaDevs.com

HolaDevs is an online community of programmers and software lovers.
You can check other people responses or create a new question if you don't find a solution

Powered by:

X