我正在努力清除地图中的所有折线,我只清楚最新的。
var polylines;
// add map polylines
function addPolyline(polyArray, colour) {
polylines = L.polyline(polyArray, {color: colour});
polylines.addTo(map);
}
// clear polylines
function clearPolylines() {
map.removeLayer(polylines);
}
其中addPolylines被多次调用,而clear Polylines被调用一次。如何清除地图上的所有折线?
答案 0 :(得分:21)
你必须记住它们或者作弊并偷看map._layers
才能找到它们。
EDIT通过@Ben添加示例代码:
function clearMap() {
for(i in m._layers) {
if(m._layers[i]._path != undefined) {
try {
m.removeLayer(m._layers[i]);
}
catch(e) {
console.log("problem with " + e + m._layers[i]);
}
}
}
}
答案 1 :(得分:1)
您可以将折线添加到layerGroup,并轻松地将其添加到地图或从地图中删除。像这样:
pLineGroup = L.layerGroup()
var latlngs = [
[45.51, -122.68],
[37.77, -122.43],
[34.04, -118.2]
];
this.pLineGroup.addLayer(L.polyline(latlngs, {color: 'red'}))
pLineGroup.addTo(map)
pLineGroup.removeFrom(map)
答案 2 :(得分:0)
以下内容将删除多边形和标记,但将图像切片保留在背景中:
for (i in map._layers) {
if (map._layers[i].options.format == undefined) {
try {
map.removeLayer(map._layers[i]);
} catch (e) {
console.log("problem with " + e + map._layers[i]);
}
}
}
答案 3 :(得分:0)
您可以创建一个数组来存储地图中存在的所有折线。
var polylines = [];
创建每条折线时,我们将其添加到数组中:
var polyline = new L.Polyline(latlongs, {
color: 'red',
opacity: 1,
weight: 1,
clickable: false
}).addTo(map);
polylines.push(polyline);
现在,当我们需要从地图上清除多段线时,我们可以这样做:
polylines.forEach(function (item) {
map.removeLayer(item)
});
答案 4 :(得分:0)
一些答案建议使用 datetime64[ns]
,它应该是一个 today_date = pd.to_datetime(dt.date.today())
final_df['Age'] = today_date - final_df["Contact Birth Date"]
属性,不应使用。最好使用 <form method="POST" class="rsvp-form js-form" id="rsvp-form" action="php/rsvp.php">
<div class="d-md-flex justify-content-between">
<div class="rsvp-form__left">
<div class="rsvp-form-field">
<input type="text" name="fullname" placeholder="Full Name" required>
</div>
<div class="rsvp-form-field">
<input type="email" name="email" placeholder="Your E-mail" class="js-email" required />
</div>
<div class="rsvp-form-field">
<input type="text" name="guests" placeholder="Will you be bringing a plus one?" required>
</div>
<div class="rsvp-form-field">
<select name="attending" required tabindex="1">
<option value="" disabled selected>When we say 'I do', will we be seeing you?</option>
<option value="Yes, wouldn't miss it for the world!"></option>
<option value="No, will celebrate from afar!"></option>
<option value="ceremony">Ceremony</option>
<option value="party">Dinner & Party</option>
</select>
</div>
</div>
<div class="rsvp-form__right">
<div class="rsvp-form-field h-100">
<textarea rows="4" placeholder="Your Message" class="h-100" name="message"></textarea>
</div>
</div>
</div>
<button type="submit" class="rsvp-form-submit js-submit">
<span>Send</span>
</button>
</form>
类型的 API。
此外,您会发现如果 int
没有附加层,# Trying to make it have a special character when file is printed such as "$" Example: $2600
savings = '$' + input("How much money do you have in your savings: ")
deposits = '$' + input("How much money do you put in deposits: ")
会崩溃,因为 map._layers
将是 private
。
我想提出以下方法,它也会跳过您的归因:
L.Map