의 당신이 당신의 코드에서 모델 Map을 가지고있는 것처럼 매끄러운 가정 해 봅시다 :보기에
public class MapModel
{
/// <summary>
/// Lattitude on map
/// </summary>
public decimal Lat { get; set; }
/// <summary>
/// Longtidute on map
/// </summary>
public decimal Lon { get; set; }
/// <summary>
/// Map zoom level
/// </summary>
public int Zoom { get; set; }
}
장소 Google지도 스크립트
<head runat="server">
<title>Index</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
function initialize()
{
var mapDiv = document.getElementById('MapDiv');
var map = new google.maps.Map(mapDiv, {
center: new google.maps.LatLng(<%= Model.Lat %>, <%= Model.Lon %>),
zoom: <%= Model.Zoom %>,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
google.maps.event.addListener(map, 'click', function(event)
{
// Puts coordinates to form (then pass to DB using Ajax, etc)
document.getElementById("Lat").value = event.latLng.lat();
document.getElementById("Lon").value = event.latLng.lng();
document.getElementById("Zoom").value = map.getZoom();
});
}
google.maps.event.addDomListener(window, 'load', initialize);
<div id="MapDiv" style="width: 500px; height: 500px"></div>
<input type="text" id="Lat" value="0" /><br />
<input type="text" id="Lon" value="0" /><br />
<input type="text" id="Zoom" value="0" /><br />
감사합니다, 나는 복식으로 모델에 길고 위도 정의 할 수 ? 십진법은 내가 아는 한 돈을위한 것이다. – mans
확실히 두 가지 용도로 사용하십시오. –