2010-12-09 4 views
0

Вот некоторые HTML код, который я написал:Google Map не появляется


В голове у меня увязывать cities.js, map.js и Google API

<div id="top"> 
    <a href="index.php"><img alt="Harvard University" src="Images/logo.jpg"></a> 
    </div> 

    <div id="logo"> 
    Harvard Abroad: Mapped 
    </div> 

    <div id="button"> 
    <input onclick="mark();" type="button" value="Map"> 
    </div> 

    <div id="map"> 
    </div> 

Как-то он не загружает карту. Файл, который я связал выше, map.js выполняет загрузку, и похоже, что он не связан должным образом, потому что я включил в него документ document.write, который не печатает.

Вот код map.js (я связать его в указанном файле), если это помогает:

// default latitude 
var LATITUDE = 42.3745615030193; 

// default longitude 
var LONGITUDE = -71.11803936751632; 

// global reference to map 
var map = null; 

// load version 3 of the Google Maps API 
google.load("maps", "3", {other_params: "sensor=false"}); 

/* 
* void 
* load() 
* 
* Loads map. 
*/ 

function load() 
{ 
    document.write("hi"); 
    // embed map 
    var latlng = new google.maps.LatLng(LATITUDE, LONGITUDE); 
    map = new google.maps.Map(document.getElementById("map"), { 
    center: latlng, 
    disableDefaultUI: true, 
    mapTypeId: google.maps.MapTypeId.ROADMAP, 
    navigationControl: true, 
    scrollwheel: true, 
    zoom: 17; 
    }); 

    // prepare test icon for map 
    testplacemarker = new google.maps.Marker({ 
    map: map, 
    title: "Your home!" 
    }); 
} 

/* 
* void 
* mark() 
* 
* Markes locations of study abroad programs all around the world map 
*/ 

function mark() 
{ 
    document.write("hi"); 
    // mark programs 
    for (var city in CITIES) 
    { 
     // plant cities on map 
     new google.maps.Marker({ 
     icon: "can't show hyperlink", 
     map: map, 
     position: new google.maps.LatLng(CITIES[city].latitude, CITIES[city].longitude), 
     title: City 
     }); 
    } 
} 

Also, just a heads up, cities.js is just an array like so: 

var = CITIES { 
    "Buenos Aires": 
    {latitude: -34.6084, longitude: -58.3732}, 
    "Santiago": 
    {latitude: -33.4254, longitude: -70.5665}, 

Я должен получить эту страницу менее чем за 1 час. Я был бы признателен за любую помощь, которую вы можете мне дать, поскольку я пытался это сделать уже какое-то время. Я думаю, что есть небольшая ошибка, которая останавливает запуск моего javascript (document.writes, который я вставил, не печатает, что означает, что map.js никогда не связан).

+0

Пожалуйста, смотрите в консоли ошибок Javascript первый. Вы наверняка найдете там какие-то сообщения. – 2010-12-09 12:19:18

+0

И, пожалуйста, отметьте весь код кодами кода. – Kimtho6 2010-12-09 12:21:03

ответ

0

Во-первых, вы должны создать объект map

var map = new GMap2(document.getElementById("map")); 
    map.addControl(new GLargeMapControl()); 
    map.addControl(new GMapTypeControl()); 
Смежные вопросы