Jump to content

bugs no map.clearOverlays();


Recommended Posts

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">
 <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);

 background : black;
 font-family : verdana;
 font-size: 12px;
       border : 1px solid #efefef;
<body onload="initialize()">
 <table border="0" width="100%" cellspacing="0" cellpadding="0">
<td width="50">
   // Please add your database details to make it work
  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 width="200" id="country"></td>
 <tr><td colspan="4" style="height: 520px;">
 <div id="map_canvas" style="width: 1020px; height: 500px; top:10px;"></div>
 <tr><td colspan="4"><br>
<script language="Javascript">

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

    if(data != "city")
     var obj = jQuery.parseJSON(msg);
     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;
     $("#ajax_response").html('<div style="text-align:left;">No Matches Found</div>');

esquecei da outra parte esta ai

  // Please add your database details to make it work
  mysql_select_db("map") or die(mysql_error());
 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'].'",';
    echo '"Count":"' . mysql_num_rows($sql) . '"}';
   while ($row = mysql_fetch_assoc($sql)) {
      echo '{"Latitude' . $i . '":"'.$row['Latitude'].'","Longitude' . $i . '":"'.$row['Longitude'].'","Descricao' . $i . '":"'.$row['Descricao'].'","Count":"1"}';
Edited by brunoais
Link to comment
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.