Skip to content

Commit

Permalink
fix custom infowindow position, close #873
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzhenn committed Apr 5, 2019
1 parent 960f5f6 commit 8b2bffd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/layer/tile/WMSTileLayer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { extend } from '../../core/util';
import Browser from '../../core/Browser';
import TileLayer from './TileLayer';

/**
Expand Down
2 changes: 2 additions & 0 deletions src/ui/InfoWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ class InfoWindow extends UIComponent {
const o = new Point(-size['width'] / 2, 0);
if (!this.options['custom']) {
o._sub(4, 12);
} else {
o._sub(0, size['height']);
}
const owner = this.getOwner();
if (owner instanceof Marker || owner instanceof MultiPoint) {
Expand Down
18 changes: 18 additions & 0 deletions test/geometry/ui/Geometry.InfowindowSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ describe('Geometry.InfoWindow', function () {
expect(position.round().toArray()).to.be.eql([633, 25]);
});

it('custom infowindow position', function () {
// test infowindow's position with frame offset
var marker = new maptalks.Marker(center.add(0.01, 0.01));
marker.addTo(layer);
var options = {
title: 'title',
content: '<div style="width:400px;height:100px;">this is a customized infowindow.</div>',
animation : false,
custom: true
};
marker.setInfoWindow(options);
map.setCenter(marker.getCenter());
marker.openInfoWindow();
var w = marker.getInfoWindow();
var position = w.getPosition();
expect(position.round().toArray()).to.be.eql([433, -109]);
});

it('autoOpen on click', function (done) {
var marker = new maptalks.Marker(center);
marker.addTo(layer);
Expand Down

0 comments on commit 8b2bffd

Please sign in to comment.