Mapbox simplestyle blocks popupContent? Using pointToLayer a
Mapbox simplestyle blocks popupContent? Using pointToLayer and onEachFeature
我在Mapbox中使用这个函数与geoJson使用simplestyle的样式标记
var groupThree = new L.LayerGroup();
L.geoJson(layerThree, {
pointToLayer: L.mapbox.marker.style,
style: function (feature) {
return feature.properties;
}
}, {
onEachFeature: onEachFeature
}).addTo(groupThree);
但是当我运行它时,当我点击标记时,我无法获得弹出窗口。下面是popupContent的函数:
var popupContent = "";
function onEachFeature(feature, layer) {
if (feature.properties && feature.properties.popupContent) {
popupContent = feature.properties.popupContent;
}
layer.bindPopup(popupContent);
}
这是我的小提琴显示标记没有简单的风格,有工作的弹出框,和简单的风格,其弹出框不起作用的标记。
pointToLayer和onEachFeature干扰?我怎样才能让它工作?
一切正常,除了一个语法错误:
var groupTwo = new L.LayerGroup();
L.geoJson(layerTwo, {
pointToLayer: L.mapbox.marker.style,
style: function(feature) { return feature.properties; }
}, {onEachFeature: onEachFeature}).addTo(groupTwo);
^
^
在这里,您将onEachFeature
作为L.geoJson
的单独参数传递,但L.geoJson
中没有第三个参数。所以基本上你创建了两个对象而不是一个。
var groupTwo = new L.LayerGroup();
L.geoJson(layerTwo, {
pointToLayer: L.mapbox.marker.style,
style: function(feature) { return feature.properties; },
onEachFeature: onEachFeature
}).addTo(groupTwo);
groupThree
的情况相同。
相关文章:
- 如何通过引用var Using DataTables来进行分页或排序
- Object.prototype using 'this'
- using LocalStorage ionic 2
- jQuery Replacing, Using arrays
- Using jQuery with classes from ES6
- Dropdownlist using javascript
- Tic-Tac-Toe using React JS
- 在jqueryui中更改关键字using
- Using php mktime()
- Twitter api using Javascript
- Bootstrap-Datepicker not selecting date when using "set
- fetch data from db using javascript & php
- Using closures in node js
- googleTagManager using JQueryMobile
- Javascript Object - using jQuery and this
- Googlemaps Javascript API KML layer - Using Open charge map
- jquery using json object
- MVC3 C# Razorview Printing a PartialView using Javascript
- focus Using Jquery <tr> <td>
- Mapbox simplestyle blocks popupContent? Using pointToLayer a