Skip to content

Instantly share code, notes, and snippets.

@scriptdev
Last active April 19, 2024 01:21
Show Gist options
  • Save scriptdev/50b2d34954adfcb0264f29bd17701009 to your computer and use it in GitHub Desktop.
Save scriptdev/50b2d34954adfcb0264f29bd17701009 to your computer and use it in GitHub Desktop.
PEGAR COORDENADAS LATITUDE e LONGITUDE E ABRIR NO MAPA
<?php
public static function onAbrirMapa($param = null)
{
try
{
TScript::create("
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
$('#latitude').val(latitude);
$('#longitude').val(longitude);
var url = 'https://www.google.com/maps?q=' + latitude + ',' + longitude;
window.open(url, '_blank');
});
}
");
}
catch (Exception $e)
{
new TMessage('error', $e->getMessage());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment