-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Fix geojson issue with marker cluster #1188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -413,22 +413,23 @@ class GeoJson(Layer): | |
} | ||
}); | ||
}; | ||
var {{ this.get_name() }} = L.geoJson(null, { | ||
{%- if this.smooth_factor is not none %} | ||
smoothFactor: {{ this.smooth_factor|tojson }}, | ||
{%- endif %} | ||
onEachFeature: {{ this.get_name() }}_onEachFeature, | ||
{% if this.style %} | ||
style: {{ this.get_name() }}_styler, | ||
{%- endif %} | ||
}).addTo({{ this._parent.get_name() }}); | ||
var options = { | ||
{%- if this.smooth_factor is not none %} | ||
smoothFactor: {{ this.smooth_factor|tojson }}, | ||
{%- endif %} | ||
onEachFeature: {{ this.get_name() }}_onEachFeature, | ||
{% if this.style %} | ||
style: {{ this.get_name() }}_styler, | ||
{%- endif %} }; | ||
{%- if this.embed %} | ||
{{ this.get_name() }}.addData({{ this.data|tojson }}); | ||
var {{ this.get_name() }} = L.geoJson( | ||
{{ this.data|tojson }}, options).addTo({{ this._parent.get_name() }}); | ||
{%- else %} | ||
$.ajax({url: {{ this.embed_link|tojson }}, dataType: 'json', async: true, | ||
success: function(data) { | ||
{{ this.get_name() }}.addData(data); | ||
}}); | ||
var json_url = $.ajax({url: {{ this.embed_link|tojson }}, dataType: 'json', async: true }) | ||
$.when(json_url).done(function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can link this to the ajax call directly: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you tried? Because the problem I had was related with async ajax request and because of that I used a variable to check if the request was finished. I don't have experience with JS. I just searched about it and I found that solution in a blog post. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems to work here, and is also listed in the examples in the jQuery documentation, so assume it should be fine. |
||
var geo_json_32b06f4a0e6d419c8f501b4e6c43bc57 = L.geoJson(json_url.responseJSON | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem with this is that this breaks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, in fact it breaks. I wasn't aware of it. I just tried your PR and works as expected 👍 |
||
, options).addTo({{ this._parent.get_name() }}); | ||
}); | ||
{%- endif %} | ||
{% endmacro %} | ||
""") # noqa | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you remove the indentation here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be automatic linting, I didn't see it. Sorry