C#에서 asp.net을 사용하고 있습니다. 자바 스크립트를 사용하여 애플리케이션에 Google지도를 삽입했습니다. 위도와 경도를 입력하면 Google지도에 위치가 표시됩니다. 이제는 데이터베이스에서 위도가 & lng 걸리고 그 위치를 보여주고 싶습니다.SQL Server에서 JavaScript 코드에서 사용할 값을 가져 오는 방법은 무엇입니까?
여기 내 코드입니다 :
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC6v5-2uaq_wusHDktM9ILcqIrlPtnZgEk&sensor=false">
</script>
<script type="text/javascript">
function initialize() {
var lat = document.getElementById('txtlat').value;
var lon = document.getElementById('txtlon').value;
var myLatlng = new google.maps.LatLng(lat, lon)
var mapOptions = {
center: myLatlng,
zoom: 18,
mapTypeId: google.maps.MapTypeId.ROADMAP,
marker: true
};
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng
});
marker.setMap(map);
}
</script>
</head>
<body >
<table>
<tr>
<td class="style3">Enter Latitude:</td>
<td><input type="text" id="txtlat" value="" onclick="return txtlat_onclick()" /> </td>
</tr>
<tr>
<td class="style3">Enter Longitude:</td>
<td><input type="text" id="txtlon" value="" onclick="return txtlon_onclick()" /> </td>
</tr>
<tr>
<td> </td>
<td><input type="button" value="Submit" onclick="javascript:initialize()" /> </td>
</tr>
</table>
<div id="map_canvas" style="width: 535px; height: 347px"></div>
</body>
</html>
와 데이터베이스에 연결하는 방법이 문서가 있습니까? –
stackoverflow는 사람들에게 코드를 작성하도록 요청하는 곳이 아닙니다. – Win
데이터 액세스 코드는 어디에 있습니까? 아마도 우리가 지금까지 얻은 것을 보여 주면 도움이 될 수 있습니다. –