我一直在處理這幾個小時,我仍然不知道如何去做。谷歌地圖如何顯示只有一個標記?
我的目標是在搜索彼此靠近的地址時僅顯示一個標記。
下面你有我在我的HTML中使用的代碼爲了搜索地址,注意 - 我正在開發一個Windows應用程序,這樣做,在這種情況下,你可能會發現一些缺少的東西,這是通過.NET Windows應用程序進行
HTML代碼
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src="http://maps.google.com.mx/maps/api/js?sensor=true&language=es"></script>
<script type="text/javascript">
var G = google.maps;
var map;
var geocoder = new G.Geocoder();
var marker;
var markersArray = [1];
function initialize() {
createMap();
geocode('Chicago');
}
function createMap() {
var myOptions = {
center: new G.LatLng(0,0),
zoom: 17,
mapTypeId: G.MapTypeId.ROADMAP
}
map = new G.Map(document.getElementById("map_canvas"), myOptions);
}
function geocode(address){
geocoder.geocode({ 'address': (address ? address : "Miami Beach, Florida")}, function (results, status) {
if (status == G.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
marker = new G.Marker({
map: map,
animation: google.maps.Animation.DROP,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>
閱讀以前的職位,我知道,if/else語句已被使用,但不能得到它的權利。
你的幫助是非常感謝。
利奧P.
Google語音(在標題中)與此有什麼關係? – geocodezip
我的錯誤,我正在考慮從谷歌語音中獲得的語音郵件,我會糾正它。謝謝你指出。 – TopoX