<?php ?>
<!DOCTYPE html>
<html>enter code here
<head>
那是底部的 Map_canvas 吗?
<style type="text/css">
html { height: 100% }
body { height: 100%; }
#map_canvas { height: 50% ; width:50%}
</style>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
var map;
var marker2;
function initialize()
{
var athens = new google.maps.LatLng(37.958592, 23.686191);
var myOptions = {
zoom: 12,
center: athens,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
var marker1 = new google.maps.Marker({
position: athens,
map: map,
title: ""
});
这是自动完成部分。很可能是这里的错误。//----------------------------自动完成---------- ----
var input = document.getElementById('location');
var autocomplete = new google.maps.places.Autocomplete(input);
google.maps.event.addListener(autocomplete, 'place_changed', function() {
infowindow.close();
marker.setVisible(false);
input.className = '';
var place = autocomplete.getPlace();
if (!place.geometry) {
// Inform the user that the place was not found and return.
input.className = 'notfound';
return;
}
var address = '';
if (place.address_components) {
address = [
(place.address_components[0] && place.address_components[0].short_name || ''),
(place.address_components[1] && place.address_components[1].short_name || ''),
(place.address_components[2] && place.address_components[2].short_name || '')
].join(' ');
}
infowindow.setContent('<div><strong>' + place.name + '</strong><br>' + address);
});
setupClickListener('changetype-geocode', ['geocode']);
// autocomplete results:
google.maps.event.addDomListener(window, 'load', initialize);
//---------------------------------------------------------------
这些功能用于标记放置,添加新的和删除以前的标记
function putMarker(Location)
{
var newpos = new google.maps.LatLng(Location);
marker2 = new google.maps.Marker({
position: newpos,
map: map,
title: ""
});
}
function addMarker()
{
var Location = document.getElementById("lacation").value;
var title= document.getElementById("mark").value;
var newpos = new google.maps.LatLng(Location);
marker2 = new google.maps.Marker({
position: newpos,
map: map,
title: title
});
}
function removeMarker()
{
marker2.setMap(null);
}
</script>
</head>
这是身体
<body onload="initialize()">
<div id="map_canvas" style="float: left; margin-right: 40px;border: 1px solid black;"></div>
<div id="Panel" style="border: 1px solid black;" >
<table>
<tr>
<td>Location:</td>
<td><input type="text" id="location" name="Location search"/></td>
<tr><br>
<td> Title:</td>
<td><input type="text" id="mark" name="Title of Marker"/></td>
</tr><br>
<td>What the problem is?:</td>
<td><textarea rows="3" cols="50" name="explaination"></textarea></td>
</tr><br>
<td><input type="button" value="Add" id="buttonadd" onclick="addMarker()"/></td>
<td><input type="button" value="Remove" id="buttonremove" onclick="removeMarker()"/></td>
</table>
</div><br><br>
</body>
</html>**
好吧,地图无法加载(这是主要问题,但“自动完成”也失败了。也许更有经验的眼睛可以看到我看不到的错误