2gis-maps
Version:
Interactive 2GIS maps API, based on Leaflet
41 lines (33 loc) • 1.16 kB
HTML
<html>
<head>
<title>projectDetector demo</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="http://maps.api.2gis.ru/2.0/loader.js"></script>
</head>
<body>
<div id="map" style="width: 100%; height: 600px; border: 1px solid #ccc;"></div>
<script type="text/javascript">
DG.then(function () {
var currentProjectBound,
map = new DG.Map('map', {
center:new DG.LatLng(54.980206086231, 82.898068362003),
zoom:10,
key: DG.config.key || 'Your API access key'
});
map.on('projectchange', function (e) {
// projectchange event
var bounds = e.getProject().latLngBounds;
currentProjectBound = DG.rectangle(bounds, {color:"#f03", weight:1}).addTo(map);
});
map.on('projectleave', function (e) {
// projectleave event
if (currentProjectBound) {
currentProjectBound.onRemove(map);
}
});
});
</script>
</body>
</html>