Я пытаюсь добавить карту Google на свою веб-страницу с помощью asp.net. Используя код, приведенный ниже карты Google, отображается в течение нескольких миллисекунд, а затем исчезает. Я проверил элементы на консоли и отобразилось следующее сообщение: «Ошибка типа« Неподчиненная ошибка: невозможно прочитать свойство »« null ». Пожалуйста, помогите мне найти решение этой проблемы.add google map "Uncaught Type Error: Невозможно прочитать свойство 'style' of null"
<script type="text/javascript">
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
function initialize() {
directionsDisplay = new google.maps.DirectionsRenderer();
var mapOptions = {
zoom: 7,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: new google.maps.LatLng(41.850033, -87.6500523)
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById('directions-panel'));
var control = document.getElementById('control');
control.style.display = 'block';
Uncaught TypeError: Cannot read property 'style' of null
map.controls[google.maps.ControlPosition.TOP_CENTER].push(control);
}
function calcRoute() {
var start = document.getElementById('start').value;
var end = document.getElementById('end').value;
var request = {
origin: start,
destination: end,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function (response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
Разве это не очевидно? Он говорит, что переменная 'control' равна нулю –