Google Maps API를 사용하고 예제를 복사하여 body onload에서 호출되는 "초기화"라는 함수로 끝났습니다.Google지도 API 3 body onload에 넣지 않고 초기화하는 방법
콘텐츠 태그 소유자 내에 배치 된 몇 가지 다른 사용자 컨트롤에서지도를 사용하므로 body 태그가 마스터 페이지에 있습니다.
master 페이지에 onload를 두지 않고 usercontrol에서 직접 initialize를 호출하는 방법이 있습니까? 이상적으로는 사용자 정의 컨트롤을 독립 실행 형 컨트롤로 설정하여 마스터 페이지 본문에 액세스하지 않고 페이지에 삽입 할 수 있습니다.
사용자 컨트롤의 내 페이지로드에서 (시작 스크립트 추가로) 초기화 기능을 호출했지만 매핑이 표시되지 않았습니다.
제안 사항?
내 코드 :
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">/script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
var map;
var geocoder;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(51.8052184317649, -4.965819906250006);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
$.ajax({
type: "POST",
url: "/GoogleMapsService.asmx/GetPointers",
contentType: "application/json; charset=utf-8",
dataType: "json",
beforeSend: function() {
$(".loadingData").html("<p>Loading data..</p>");
},
complete: function() {
$(".loadingData").html("");
},
cache: true,
success: mapPoints,
error: onError
});
}
function onError(xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(xhr.responseText);
}
function mapPoints(response) {
if (response.d != null) {
if (response.d.length > 0) {
for (var i = 0; i < response.d.length; i++) {
plotOnMap(response.d[i].Id, response.d[i].Name,
response.d[i].Lat, response.d[i].Long,
response.d[i].ShortDesc)
}
}
}
}
내 테스트 마스터 페이지에
가 :<body onload="initialize()">
<form runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"></asp:ScriptManager>
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
</form>
</body>
이 링크는 도움이 될 수 있습니까? http://stackoverflow.com/questions/29792518/why-didnt-work-my-classic-asp-source-code – pcs