传单缩放控制位置错误

Leaflet zoom control position error

我想将缩放控件的位置更改为 'topRight'。以下是我的代码(这里坐标、缩放、子域和属性是先前定义的):

var map = L.map('map', {zoomControl: false}).setView([coords.latitude, coords.longitude], zoom);

L.control.zoom({
    position: 'topRight'
}).addTo(map);

L.tileLayer(mapquestUrl, {
    subdomains: subDomains,
    attribution: attrib,
    maxZoom: 18
}).addTo(map);

这在 firefox 中给了我 TypeError: n is undefined,在 chrome 中给了我 Uncaught TypeError: Cannot read property 'appendChild' of undefined

删除 {zoomControl: false}L.control.zoom({ position: 'topRight'}).addTo(map); 工作正常,默认控制位置在左上角。

打字错误,必须写'topright',而不是'topRight'

Control Positions reference