I am passing Latitude
and Longitude
by link to direction.html
file
.../direction.html?latlng=53.456269068499545,-6.220780313014984
how can I get this values to get lat and lng separately
I am passing Latitude
and Longitude
by link to direction.html
file
.../direction.html?latlng=53.456269068499545,-6.220780313014984
how can I get this values to get lat and lng separately
You can use hashtag, that is passing the value latitude and longitude like this ursite/path#53.456269068499545,-6.220780313014984
var tag = window.location.hash;
tag = tag.substring(1,tag.length);
var co_ordinate = tag.split(",")
var latlng = co_ordinate[0]
var logitude = co_ordinate[1];
Because you're passing a single variable, you could just split the data using the comma. The result would be an array.
latlng=53.456269068499545,-6.220780313014984
var res = latlng.split(",");
Well Im not sure what language you are using to script the page. I have ideas for PHP.
//you get the variable being passed
if (isset ($_Get['longlat'];) {
$longlat = $_GET['longlat'];
//then you split them with explode
$longlat = explode(',', $longlat);
$long = $longlat[0];
$lat = $longlat[1];
thats about it. read the manual on explode to get the correct syntax, but this is the gist of what you want i believe
You can use split to pull the string into an array, splitting it by the comma, then just assign each of the array's values to a new variable for lat and lng.
I would also parse the data into floats if you are using it as actual coordinate data later on, rather than just printing it.
For:
String latlng=53.456269068499545,-6.220780313014984;
Use:
var coords = latlng.split(",");
float lat = parseFloat(coords[0]);
float lng = parseFloat(coords[1]);