[英]Adding functionality to mapbox.js
我試圖重寫grid_control.js
在MapBox允許從幾個提示gridControl
到在同一個盒子的同時一起出現。
gridControl
被激活,因此:
var gridLayer = L.mapbox.gridLayer('example-map.sdfagg22gd');
var tileLayer = L.mapbox.tileLayer('example-map.sdfagg22gd')
map.addLayer(tileLayer);
map.addLayer(gridLayer);
map.addControl(L.mapbox.gridControl(gridLayer));
但是,我不想重寫源代碼,而是想擴展GridControl
類,並使代碼與將來的mapbox.js
版本更加兼容。
var GridControl = L.Control.extend({
options: {
pinnable: true,
follow: false,
sanitizer: require('sanitize-caja'),
touchTeaser: true,
location: true
},
我應該怎么做,建議這樣做嗎?
另外,關於如何同時允許多個工具提示的任何想法? 我是否需要一個計數器來獲取活動的工具提示並根據此操作重做所有操作? 任何指針將不勝感激。
據我了解,並發工具提示的可能性是可能的,因為帶有工具提示內容的兩個單獨的框將顯示為{follow : false}
選項。 但是如何將其放入以鼠標為中心的移動工具提示(由{follow: true}
激活)?
只是:
// get gridControl object and pass it for modification
var gridControl = L.mapbox.gridControl(gridLayer, {follow:true});
// modify the prototype
gridControl.__proto__._onPopupClose = function() {
this._currentContent = null;
this._lastContent = null;
this._pinned = false;
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.