0
喜IAM的JavaScript和谷歌地圖的新手,努力實現與側邊欄下面簡單的地圖是我的代碼谷歌地圖可點擊側邊欄
<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);
});
}
當前夕我在側邊欄INEE點擊城市去那個地圖,點了marker..i嘗試,但一些missing..Any幫助將不勝感激
thanks geocodezip .. but could not find much .. as my side bar is simple – hari86