Jump to content
dudusf04

bugs no map.clearOverlays();

Recommended Posts

dudusf04

ola para todos!

galera estou com um probleminha no clearoverlays, sempre que ele esta sem as // ele nao faz a busca e esta com a // ele nao limpa e onde esta os markes e troco de ponto e deixa os markes do ponto..

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
 <title> Google Maps Tutorial </title>
 <meta name="generator" content="Bluefish 2.2.0" >
 <meta name="author" content="Eduardo Farias" >
 <meta name="Keywords" content="">
 <meta name="Description" content="">
 <script src="jquery.js"></script>
 <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
 <script type="text/javascript">var switchTo5x=true;</script>
 <script type="text/javascript">
   var map;

   function initialize() {
   var latlng = new google.maps.LatLng(41.153843, -8.625984);
    var myOptions = {
       zoom: 4,
       center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
   }
function place_marker(lt,lg, des){

 var latlng = new google.maps.LatLng(lt,lg);

 var marker = new google.maps.Marker({
   position: latlng,
   map: map,
   icon: 'loko.png'
 });
 var iw = new google.maps.InfoWindow({
   content: des
 });
 google.maps.event.addListener(marker, 'click', function() {
   iw.open(map, marker);
 });

  map.setZoom(8);
  map.setCenter(marker.getPosition());
}
</script>
 <style>
   body{
 background : black;
 font-family : verdana;
 font-size: 12px;
   }
   select{
       border : 1px solid #efefef;
   }
 </style>
</head>
<body onload="initialize()">
<br>
 <table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
<td width="50">
 <?php
   // Please add your database details to make it work
  mysql_connect("localhost","root","Eduardo1234");
  mysql_select_db("map") or die(mysql_error());
   $sql = mysql_query("SELECT DISTINCT Country.CountryId, Country.* FROM country INNER JOIN cities ON country.countryid = cities.CountryId INNER JOIN lojas ON lojas.CityId = cities.CityId");
   echo '<select name="country">';
   echo '<option value=0>Select</option>';
   while($row = mysql_fetch_array($sql)){
    echo '<option value="'.$row['countryid'].'">'.$row['country'].'</option>';
   }
   echo "</select>";
 ?>
</td>
<td width="200" id="country"></td>
 </tr>
 <tr><td colspan="4" style="height: 520px;">
 <div id="map_canvas" style="width: 1020px; height: 500px; top:10px;"></div>
 </td></tr>
 <tr><td colspan="4"><br>
 </td></tr>
 </table>
</body>
</html>
<script language="Javascript">
<!--
$().ready(function(){
 $("select").live('change',function(){

  var countryId = $(this).val();
  var data   = $(this).attr("name");
  $.ajax({
     type: "POST",
     url: "get_list.php",
     data: "cid="+countryId+"&data="+data,
     success: function(msg){
   if(msg != 0){

    if(data != "city")
     $("#"+data).html(msg);
    else{
     var obj = jQuery.parseJSON(msg);
     //map.clearOverlays();
     var i = obj.Count;

     for (j = 0; j < i; j++)
     {
      var tmpLatitude = "Latitude" + j;
      var tmpLongitude = "Longitude" + j;
      var tmpDescricao = "Descricao" + j;    
      var lt = obj[tmpLatitude];
      var lg = obj[tmpLongitude];
      var des = obj[tmpDescricao];
      place_marker(lt,lg, des);
     }

     /*lt = obj.Latitude1;   
     lg = obj.Longitude1;
     place_marker(lt,lg);*/
    }
   }
   else
   {
     $("#ajax_response").fadeIn("slow");
     $("#ajax_response").html('<div style="text-align:left;">No Matches Found</div>');
   }
   $("#loading").css("visibility","hidden");
     }
   });
 });
});
//-->
</script>

esquecei da outra parte esta ai

<?php
  // Please add your database details to make it work
  mysql_connect("localhost","","");
  mysql_select_db("map") or die(mysql_error());
  extract($_POST);
 if($data == "country"){
  $sql = mysql_query("SELECT DISTINCT Cities.City, Cities.* FROM cities INNER JOIN lojas ON lojas.CityId = cities.CityId where cities.countryid = $cid");
  $html = '<select name="city"><option value=0>Select</option>';
  while($row = mysql_fetch_array($sql)){
    $html .= '<option value="'.$row['CityId'].'">'.$row['City'].'</option>';
     }
  $html .= "</select>";
  echo $html;
  }

  if($data == "city"){
  $sql = mysql_query("select * from lojas where CityId = $cid");

  $i = 0;
  if (mysql_num_rows($sql) > 1)
  {
   if ($i == 0)
    echo "{";
    while ($row = mysql_fetch_assoc($sql)) {

     echo '"Latitude' . $i . '":"'.$row['Latitude'].'","Longitude' . $i . '":"'.$row['Longitude'].'","Descricao' . $i . '":"'.$row['Descricao'].'",';
   $i++;
    }
    echo '"Count":"' . mysql_num_rows($sql) . '"}';
  }
  else
  {
   while ($row = mysql_fetch_assoc($sql)) {
      echo '{"Latitude' . $i . '":"'.$row['Latitude'].'","Longitude' . $i . '":"'.$row['Longitude'].'","Descricao' . $i . '":"'.$row['Descricao'].'","Count":"1"}';
   }
  }  
  }
?>  

Edited by brunoais
geshi

Share this post


Link to post
Share on other sites
HappyHippyHippo

a class map (da google maps) não tem o método clearOverlays


IRC : sim, é algo que ainda existe >> #p@p

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. 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.