2012-05-06 17 views
0

上のサーバーとクライアント側の接続私たちは、HTMLのVisual Studioプロジェクト

<!DOCTYPE html> 
<html> 
<head> 
<title>Google Maps</title> 
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
<script type="text/javascript" src="js/jquery-1.4.1.min.js"></script> 
<script type="text/javascript" src="js/markers.js"> 
</script> 
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255"> 
</head> 
<body><div id="map"></div> 
<input type="button" id="showmarkers" value="Show Markers" /> 

</body> 
</html> 

にこのコードを書いて、JAVASCRIPT

$(document).ready(function() { 
    $("#map").css({ 
     height:600, 
     width: 2000 
    }); 
    var myLatLng = new google.maps.LatLng(31.2402893696987, 34.7672211844361); 
    MYMAP.init('#map', myLatLng, 11); 

    $("#showmarkers").click(function(e){ 
     MYMAP.placeMarkers('markers.xml'); 
}); 
}); 

var MYMAP = { 
    map: null, 
    bounds: null 
} 

MYMAP.init = function(selector, latLng, zoom) { 
    var myOptions = { 
    zoom:zoom, 
    center: latLng, 
    mapTypeId: google.maps.MapTypeId.ROADMAP 
    } 
    this.map = new google.maps.Map($(selector)[0], myOptions); 
    this.bounds = new google.maps.LatLngBounds(); 
} 

MYMAP.placeMarkers = function(filename) { 
    $.get(filename, function(xml){ 
     $(xml).find("marker").each(function(){ 
      var name = $(this).find('name').text(); 
      var address = $(this).find('address').text(); 

      // create a new LatLng point for the marker 
      var lat = $(this).find('lat').text(); 
      var lng = $(this).find('lng').text(); 
      var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng)); 

      // extend the bounds to include the new point 
      MYMAP.bounds.extend(point); 

      var marker = new google.maps.Marker({ 
       position: point, 
       map: MYMAP.map 
      }); 

      var infoWindow = new google.maps.InfoWindow(); 
      var html='<strong>'+name+'</strong.><br />'+address; 
      google.maps.event.addListener(marker, 'click', function() { 
       infoWindow.setContent(html); 
       infoWindow.open(MYMAP.map, marker); 
      }); 
      MYMAP.map.fitBounds(MYMAP.bounds); 
     }); 

    }); 
} 

でこのコードは、私たちは、このコードを使用したいですASP上にGoogleマップを表示します。 NET(C#)のWebサイト。私たちのウェブサイトのページの1つにこのコード全体をそのままロードすることは可能ですか? ありがとう!!!!!

答えて

0

はい。新しい.aspxファイルをASP.NETプロジェクトに追加し、既定のコンテンツをHTMLに置き換えます。

<script language="javascript"> 

</script> 

をそして、そこの間に、あなたのjavascriptのコードを貼り付けます。
その後、<head>セクションのスクリプトブロックを追加します。

これで、プロジェクトの他のページからこのページへのリンクを追加できます。
それはうまくいくはずです。

関連する問題