Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions examples/search-and-hover/polygon-hover-add-search.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@
});
layer.enableMapTips({
select: tooltipFields, // pulls list of columns to query, cam have only one column
from: tableid, // pulls fusion table name referenced above
geometryColumn: geometryColumn, // pulls geometry column name, may be Address for a points map
suppressMapTips: false, // optional, whether to show map tips. default false
delay: delay, // pulls milliseconds mouse pause before send a server query. default 300.
tolerance: tolerance, // pulls tolerance in pixel around mouse. default is 6. want a bigger number for point maps
Expand Down
38 changes: 29 additions & 9 deletions src/fusiontips.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@
var queryPending = false;
var containerPos = findElPos(me.getMap().getDiv());
var tol = opts.tolerance || 6;


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove these extra line breaks

google.maps.event.addListenerOnce(maptip, 'ready', function() {
// map.mousemove may not fire consistently, so we calc latlng from DOM events
me.mousemoveListener_ = google.maps.event.addDomListener(me.getMap().getDiv(), 'mousemove', function(evt) {
Expand All @@ -192,7 +194,7 @@
var mousePos = findMousePos(evt);
var containerPx = new google.maps.Point(mousePos.x - containerPos.x, mousePos.y - containerPos.y);
currentLatLng = maptip.getProjection().fromContainerPixelToLatLng(containerPx);
delayTimeout = window.setTimeout(queryFusion, opts.delay || 400);
delayTimeout = window.setTimeout(queryFusion, opts.delay || 200);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you mean to commit this? 400 may indeed be too slow, but just wanted to check

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, not it is not necessary, this is just from my main branch where it leads to a better user experience in my case.

}
currentCursor = c;
});
Expand All @@ -215,11 +217,16 @@
px.y -= tol * 2;
var ne = prj.fromDivPixelToLatLng(px);
var bounds = new google.maps.LatLngBounds(sw, ne);
var swhere = "ST_INTERSECTS(" + opts.geometryColumn + ",RECTANGLE(LATLNG(" + bounds.getSouthWest().lat() + "," + bounds.getSouthWest().lng() + "),LATLNG(" + bounds.getNorthEast().lat() + "," + bounds.getNorthEast().lng() + ")))";
if (opts.where) {
swhere += " AND " + opts.where;
// Use the geometry column from the fusion table layer.
var geometryColumn = opts.geometryColumn || me.query.select;
var swhere = "ST_INTERSECTS(" + geometryColumn + ",RECTANGLE(LATLNG(" + bounds.getSouthWest().lat() + "," + bounds.getSouthWest().lng() + "),LATLNG(" + bounds.getNorthEast().lat() + "," + bounds.getNorthEast().lng() + ")))";
var where = opts.where || me.query.where;
if (where) {
swhere += " AND " + where;
}
var queryText = encodeURIComponent("SELECT " + opts.select + " FROM " + opts.from + " WHERE " + swhere);
// Use the table id from the fusion table layer.
var tableid = opts.from || me.query.from;
var queryText = encodeURIComponent("SELECT " + opts.select + " FROM " + tableid + " WHERE " + swhere);
queryPending = true;
queryFusionJson(latlng, queryText);
}
Expand Down Expand Up @@ -304,14 +311,27 @@
}

};
/**
* Checks where there is map tips enabled.
*/
google.maps.FusionTablesLayer.prototype.hasMapTips = function() {
if (this.maptipOverlay_) {
return true;
} else {
return false;
}
};

/**
* Disable map tips for the fusion layer.
*/
google.maps.FusionTablesLayer.prototype.disableMapTips = function() {
this.maptipOverlay_.setMap(null);
this.maptipOverlay_ = null;
google.maps.event.removeListener(this.mousemoveListener_);
this.mousemoveListener_ = null;
if (this.maptipOverlay_) {
this.maptipOverlay_.setMap(null);
this.maptipOverlay_ = null;
google.maps.event.removeListener(this.mousemoveListener_);
this.mousemoveListener_ = null;
}
};
// cleanup
var _setMap_ = google.maps.FusionTablesLayer.prototype.setMap;
Expand Down