Jump to content

google location and GET value


vaskovasilev

Recommended Posts

hello,

i am using google scripts for finding the location base ot search city or street..

everything is working if i am searching from the same index by input tag with some id..

the button is executing some javascript.

i am trying to make the search by giving parameter from other index - with $_GET['location'].

after that i put one rule - if($_GET[location]){ echo "<script type javascript.. function()."

but nothing happens.

in the function i put one alert after the if(thislocation), to see if the parameter is givven to the function ant id is, but the location didnt appear.

can you help me to understand what i am missing.

function submitQuery(thislocation) {
        if(thislocation){var query=thislocation} else {  var query = document.getElementById("location").value; }
  if (/\s*^\-?\d+(\.\d+)?\s*\,\s*\-?\d+(\.\d+)?\s*$/.test(query)) {
    var latlng = parseLatLng(query);
    if (latlng == null) {
      document.getElementById("location").value = "";
    } else {
      geocode({ 'latLng': latlng });
    }
  } else {
    geocode({ 'address': query });
  }
}
function geocode(request) {  
  resetMap();
  var hash = '';
  if (request.latLng) {
    hash = 'q=' + request.latLng.toUrlValue(6);
  } else {
    hash = 'q=' + request.address;
  }
  hashFragment = '#' + escape(hash);
  window.location.hash = escape(hash);
  geocoder.geocode(request, showResults);
}
function parseLatLng(value) {
  value.replace('/\s//g');
  var coords = value.split(',');
  var lat = parseFloat(coords[0]);
  var lng = parseFloat(coords[1]);
  if (isNaN(lat) || isNaN(lng)) {
    return null;
  } else {
    return new google.maps.LatLng(lat, lng);
  }
}

<input type="text" id="location" style="width:93%; height:30px; font-size:15px;" class="logbut" placeholder="<?php echo $lang['mapinfo'];?>" >
</td>
<td align="right" style="min-width:46px; vertical-align:middle">
    <input type="button" value="<?php echo $lang['search'];?>" class="newclassbutton" onclick="submitQuery()"/>
    <?php if($_GET['location']){?><script type="text/javascript">submitQuery('<?php echo $_GET['location'];?>')</script><?php } ?>
Link to comment
https://forums.phpfreaks.com/topic/280413-google-location-and-get-value/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.