-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