console
G7SMap.init({
id: 'map',
key: {
'bmap': 'ebAmxZxmn8hHBm1anhEcTH8j',
'gmap': 'AIzaSyBdZt3pUFIFTWKlHqUA_m6GJo_V--k84KU'
},
center: [116.3702520000, 39.8890690000],
zoom: 12
}).then(function (map) {
var point = new G7SMap.Point(116.3738450000, 39.8497120000);
var infowindow = new G7SMap.InfoWindow('我是一个infowindow', { position: point });
document.querySelector('.add-infowindow').addEventListener('click', function () {
infowindow.open(point);
});
document.querySelector('.remove-infowindow').addEventListener('click', function () {
map.clearOverlays();
});
document.querySelector('.show-infowindow').addEventListener('click', function () {
infowindow.show();
});
document.querySelector('.hide-infowindow').addEventListener('click', function () {
infowindow.close();
});
document.querySelector('.get-content').addEventListener('click', function () {
alert(infowindow.getContent());
});
document.querySelector('.set-content').addEventListener('click', function () {
infowindow.setContent('我是改变的infowindow');
});
document.querySelector('.get-pos').addEventListener('click', function () {
alert(infowindow.getPosition().toString());
});
document.querySelector('.set-pos').addEventListener('click', function () {
var point = new G7SMap.Point(116.3738450000, 39.8597120000);
infowindow.setPosition(point);
});
});
<div id="map" class="map"></div>
<div>
<button class="add-infowindow">添加infowindow</button>
<button class="remove-infowindow">移除infowindow</button>
<button class="show-infowindow">显示infowindow</button>
<button class="hide-infowindow">隐藏infowindow</button>
</div>
<div style="margin-top: 10px;">
<button class="get-content">getContent</button>
<button class="set-content">setContent</button>
<button class="get-pos">getPosition</button>
<button class="set-pos">setPosition</button>
</div>
.map {
max-width: 800px;
height: 500px;
}
.result {
color: #f60;
}