-1
\t Long = -40.00;
Lati = 150.00;
\t var map = new google.maps.Map(document.getElementById('map'), {
\t \t zoom: 10,
\t \t center: new google.maps.LatLng(Long, Lati),
\t \t mapTypeId: google.maps.MapTypeId.ROADMAP
\t });
var marker = new google.maps.Marker({
\t \t position: new google.maps.LatLng(Long, Lati),
\t \t map: map
\t });
function AddMarker() {
\t var Long = document.getElementById('longitude').value;
var Lati = document.getElementById('latitude').value;
var map = google.maps.Map(document.getElementById('map'));
\t var marker = new google.maps.Marker({
\t position: new google.maps.LatLng(Long, Lati),
\t \t \t map: map
\t \t });
}
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Google Maps Multiple Markers</title>
<script src="http://maps.google.com/maps/api/js"
type="text/javascript"></script>
</head>
<body>
<div>
\t Long :<input type="text" id="longitude" size="10" value="-40.20">
Lati :<input type="text" id="latitude" size="10" value="150.00">
<input type="submit" onclick="AddMarker()" value="Add">
</div>
<div id="map" style="width: 500px; height: 400px;"></div>
</body>
嗨
按鈕添加一個標記不工作,任何IDEIA爲什麼呢?
如果我在var map變量上使用「new」,它將起作用,但它會創建並清除已存在的標記。
預先感謝
嗨......唉唉您刪除以及初始化標誌,因爲它是沒有意義的,我thatthere,但它不工作
好謝謝... – user3801128