Shows Maps with markers which contains descriptions with links to cleverroute main-page
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.6 KiB

4 years ago
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>MarkerWithLabel Example</title>
<style type="text/css">
.labels {
color: #ea4335;
background-color: white;
font-family: Roboto, Arial, sans-serif;
font-size: 10px;
font-weight: bold;
text-align: center;
width: 40px;
padding: 2px;
border: 1px solid #999;
box-sizing: border-box;
white-space: nowrap;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBIwzALxUPNbatRBj3Xi1Uhp0fFzwWNBkE"></script>
<script src="../dist/index.dev.js"></script>
<script>
function initMap() {
var latLng = new google.maps.LatLng(49.47805, -123.84716);
var homeLatLng = new google.maps.LatLng(49.47805, -123.84716);
var map = new google.maps.Map(document.getElementById("map_canvas"), {
zoom: 12,
center: latLng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
});
var marker1 = new MarkerWithLabel({
position: homeLatLng,
draggable: false,
clickable: false,
map: map,
labelContent: "$425K",
labelAnchor: new google.maps.Point(-21, 3),
labelClass: "labels", // the CSS class for the label
labelStyle: { opacity: 0.75 },
});
var marker2 = new MarkerWithLabel({
position: new google.maps.LatLng(49.475, -123.84),
draggable: true,
map: map,
labelContent: "$395K",
labelAnchor: new google.maps.Point(-21, 3),
labelClass: "labels", // the CSS class for the label
labelStyle: { opacity: 1.0 },
});
var iw1 = new google.maps.InfoWindow({
content: "Home For Sale",
});
var iw2 = new google.maps.InfoWindow({
content: "Another Home For Sale",
});
google.maps.event.addListener(marker1, "click", function (e) {
iw1.open(map, this);
});
google.maps.event.addListener(marker2, "click", function (e) {
iw2.open(map, this);
});
}
</script>
</head>
<body onload="initMap()">
<p>
A basic example of markers with labels. Note that an information window
appears whether you click the marker portion or the label portion of the
MarkerWithLabel. The two markers shown here are both draggable so you can
easily verify that markers and labels overlap as expected.
</p>
<div id="map_canvas" style="height: 400px; width: 100%"></div>
<div id="log"></div>
</body>
</html>