2
在谷歌地圖,當我添加一個標記,我希望它是一個與谷歌提出到該位置的地址的泡沫。 我有什麼選擇可以發送標記對象(或者它是標記對象嗎?)如何添加超過(hoover)事件標記以顯示地址
在谷歌地圖,當我添加一個標記,我希望它是一個與谷歌提出到該位置的地址的泡沫。 我有什麼選擇可以發送標記對象(或者它是標記對象嗎?)如何添加超過(hoover)事件標記以顯示地址
我可以使用以下google-maps-api-v3繪製/冒泡給定的地址/郵編(不超過8個) JavaScript嵌入代碼。
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Google Maps JavaScript API v3 Example: Directions Waypoints</title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/standard.css" rel="stylesheet" type="text/css" />
<script src="https://maps-api-ssl.google.com/maps/api/js?v=3&sensor=false" type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
var directionDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
directionsDisplay = new google.maps.DirectionsRenderer();
var chicago = new google.maps.LatLng(41.850033, -87.6500523);
var myOptions = {
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: chicago }
var waypts = [];
var PtsArray = [];
//Give input as postcode/place name as a single string seperated by pipeline character as follows.
var PointsString = "LE126UW" + "|" + "NG104AH" + "|" + "B112RJ" + "|" + "London";
PtsArray = PointsString.split("|");
var length = PtsArray.length;
if (length > 2) {
for (i = 1; i < (length - 1); i++) {
waypts.push({
location: String(PtsArray[i]),
stopover: true
});
}
}
var request = {
origin: String(PtsArray[0]),
destination: String(PtsArray[length - 1]),
waypoints: waypts,
optimizeWaypoints: false,//set this to true to get optimized path else it will plot as the given input.
travelMode: google.maps.DirectionsTravelMode.DRIVING//set your travel mode here (walking,driving..)
};
directionsService.route(request, function (response, status) {
if (status == google.maps.DirectionsStatus.OK) {
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
directionsDisplay.setMap(map);
directionsDisplay.setDirections(response);
var route = response.routes[0];
var total = 0;
var numberLegs = route.legs.length;
}
else {
alert("Could not load data.." + status);
}
});
}
</script>
希望這有助於你太...