add formatter and update bindPopup method

This commit is contained in:
Juan Thomassie 2015-05-10 11:32:27 -05:00
parent d822ea1147
commit fd46874eac

View file

@ -34,6 +34,8 @@ define(function (require) {
// track the map objects // track the map objects
this.maps = []; this.maps = [];
this.tooltipFormatter = chartData.tooltipFormatter;
this.events = new Dispatch(handler); this.events = new Dispatch(handler);
// add allmin and allmax to geoJson // add allmin and allmax to geoJson
@ -541,18 +543,24 @@ define(function (require) {
* return {undefined} * return {undefined}
*/ */
TileMap.prototype.bindPopup = function (feature, layer) { TileMap.prototype.bindPopup = function (feature, layer) {
var props = feature.properties;
var popup = L.popup({ var self = this;
className: 'leaflet-popup-kibana', var lat = feature.geometry.coordinates[1];
autoPan: false var lng = feature.geometry.coordinates[0];
}) var latLng = L.latLng(lat, lng);
.setContent(
'Geohash: ' + props.geohash + '<br>' + var popup = L.popup({autoPan: false})
'Center: ' + props.center[1].toFixed(1) + ', ' + props.center[0].toFixed(1) + '<br>' + .setLatLng(latLng);
props.valueLabel + ': ' + props.count
);
layer.bindPopup(popup) layer.bindPopup(popup)
.on('mouseover', function (e) { .on('mouseover', function (e) {
var content = self.tooltipFormatter(feature);
console.log(content);
if (!content) {
return;
}
popup.setContent(content);
layer.openPopup(); layer.openPopup();
}) })
.on('mouseout', function (e) { .on('mouseout', function (e) {