Jump to content

Recommended Posts

Posted

Ola para todos!

estou com um grande problema estou ja a dias a tentar a colocar o infowindows no mapa que consegui cria, por favor se poderem me tirar umas duvidas era bestial.

function place_marker(lt,lg, des){
   var point = new google.maps.LatLng(lt,lg);
   map.setCenter(point,10);

   var marker = new GIcon(G_DEFAULT_ICON,'posto.gif');

   marker.image = "piubelle.png";
   // Set up our GMarkerOptions object
   markerOptions = { icon:marker };

   // place marker at location
   var latlng = new GLatLng(lt,lg);

   map.addOverlay(new GMarker(latlng, markerOptions));
} 
Posted

não sei que raio de documentação andas a seguir ...

function place_marker(lt,lg, des){
 var marker = new google.maps.Marker({
   position: new google.maps.LatLng(lt,lg),
   map: map,
   icon: 'posto.gif'
 });

 var iw = new google.maps.InfoWindow({
   content: des
 });

 google.maps.event.addListener(marker, 'click', function() {
   iw.open(map, marker);
 });
}
IRC : sim, é algo que ainda existe >> #p@p
Posted

isso ta uma grande mistura que ao longo do percurso tive varias duvidas então fui vendo alguns tutorias para ver se tinha alguma ideias.

o código todo para o mapa e esse

<script type="text/javascript">
   var map;
   function initialize() {
     if (GBrowserIsCompatible()) {

       map = new GMap2(document.getElementById("map_canvas"));
       map.setCenter(new GLatLng(41.153843, -8.625984), 4);
       map.setUIToDefault();
     }
   }
 function place_marker(lt,lg, des){
 var marker = new google.maps.Marker({
   position: new google.maps.LatLng(lt,lg),
   map: map,
   icon: 'posto.gif'
 });
 var iw = new google.maps.InfoWindow({
   content: des
 });
 google.maps.event.addListener(marker, 'click', function() {
   iw.open(map, marker);
 });
}

</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{
     map.clearOverlays(); 
     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;
     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>

obrigado pela ajuda!!!

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.