Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var map;
- var idInfoBoxAberto;
- var infoBox = [];
- var markers = [];
- function CriaRequest() {
- try{
- request = new XMLHttpRequest();
- }catch (IEAtual){
- try{
- request = new ActiveXObject("Msxml2.XMLHTTP");
- }catch(IEAntigo){
- try{
- request = new ActiveXObject("Microsoft.XMLHTTP");
- }catch(falha){
- request = false;
- }
- }
- }
- if (!request)
- alert("Seu Navegador não suporta Ajax!");
- else
- return request;
- }
- /**
- * Função para enviar os dados
- */
- window.onload = getDados;
- function getDados(callback) {
- // Declaração de Variáveis
- // var cep = document.getElementById("cep").value;
- var raio = $('input[name="raio"]:checked').val()
- if(raio == null || raio == undefined)
- {
- var raio = 10;
- }
- var result = document.getElementById("Resultado");
- var xmlreq = CriaRequest();
- if (navigator.geolocation) {
- navigator.geolocation.getCurrentPosition(showPosition);
- } else {
- x.innerHTML = "Seu navegador nao suporte Geolocalização.";
- }
- function showPosition(position) {
- var lat = position.coords.latitude;
- var lng = position.coords.longitude;
- lat = lat.toFixed(6);
- lng = lng.toFixed(6);
- // Iniciar uma requisição
- xmlreq.open("GET", "criando.php?raio=" + raio + "&lat=" + lat + "&lng=" + lng, true);
- // Atribui uma função para ser executada sempre que houver uma mudança de ado
- xmlreq.onreadystatechange = function(){
- // Verifica se foi concluído com sucesso e a conexão fechada (readyState=4)
- if (xmlreq.readyState == 4) {
- // Verifica se o arquivo foi encontrado com sucesso
- if (xmlreq.status == 200) {
- result.innerHTML = xmlreq.responseText;
- callback(true);
- }else{
- result.innerHTML = "Erro: " + xmlreq.statusText;
- }
- }
- };
- xmlreq.send(null);
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement