2012-09-27 6 views
0

Salut iam javascript et google maps débutant et essayer de mettre en œuvre des cartes simples avec la barre latérale qui suit est mon codeGoogle maps avec barre latérale cliquable

<script> 
     function createMarker(lat,lng) 
       { 

    alert("lat,lang"); 
        var marker = new google.maps.Marker({ 
        map: map, 
        position: latlng, 
        content:content 
        }); 
        if(icon){marker.setIcon(icon);} 

        if(center) 
        { 
        map.setCenter(latlng); 
        } 

        google.maps.event.addListener(marker, 'click', function() { 
        infowindow.setContent(this.content); 
        infowindow.open(map, this); 
        }); 

        if(action) 
        { 
        action.fnc(map,action.args); 
        } 
        return marker; 
       } 
    </script> 

<body> 
<div id="container"> 
<div id="menu" style="background-color:#FFD700;height:800px;width:100px;float:left;"> 
<table border="0"> 
<tr> 
<th>Cities</th> 
</tr> 
<tr> 
<td onclick="createMarker('40.47','73.58');">newyork</td> 
</tr> 
<tr> 
<td onclick="createMarker('41.50','87.83');">chicago</td> 
</tr> 

</table> 
</div> 


<script type="text/javascript"> 
     var map; 
     var markersArray = []; 

     function initialize() 
     { 
      var latlng = new google.maps.LatLng(12.9833, 77.5833); 
      var myOptions = { 
       zoom: 10, 
       center: latlng, 
       mapTypeId: google.maps.MapTypeId.ROADMAP 
      }; 
      map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 


      // add a click event handler to the map object 
      google.maps.event.addListener(map, "click", function(event) 
      { 
       // place a marker 
       placeMarker(event.latLng); 
      }); 
     } 

Lorsqu'Eve je clique sur la ville dans l'INEE barre latérale pour accéder à cette carte et point a marker..i essayé mais quelque chose missing..Any aide serait appréciée

Répondre

Questions connexes