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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.