Skip to main content
8 votes

Why doesn't Leaflet have cross-origin error when adding WMS layer from GeoServer, but GetFeatureInfo using ajax does

Because that is the way CORS works! loading images is always (mostly) a safe operation so the browser doesn't care where you get them from. Loading a script (javascript or xml) is potentially ...
Ian Turton's user avatar
  • 82.6k
4 votes
Accepted

Geoserver Printing Module | MapFish print service won't print

I had similar issue. Did exactly like you did. Later, I used GET and solved the issue. You just need to use encodeURI() before passing your json as the spec parameters. Try following: $("#export-...
A. Bhujel's user avatar
4 votes
Accepted

Wait until geoJSON ajax call completed

The following is the fallback function for data loading: layer_kos.on('data:loaded', function() { }) More can be found in the doc
NettaB's user avatar
  • 1,956
4 votes
Accepted

MarkerCluster don't work with geojson layer in leaflet

From your above additional code, it looks like you are loading Leaflet.markercluster script before Leaflet script: <script src="leaflet.markercluster-src.js"> <script src="http://code.jquery....
ghybs's user avatar
  • 7,233
4 votes

Displaying GeoJSON using Ajax and Leaflet?

There are several things that have to be corrected. First thing is wrong path to ajax library leaflet.ajax.min.js. Error 404 for file webmap101/htdocs/webmap101/leaflet.ajax.min.js tells you that ...
TomazicM's user avatar
  • 26.5k
3 votes
Accepted

Uncaught SyntaxError: Unexpected token < (Geoserver popup in leaflet using ajax)

The problem is in the url string. It had two problems: Additional comma at the end of layers parameter as suggest by @Stefan in comments &layers=workspace%3AlayerA,workspace%3AlayerB,workspace%...
DigitalPatwari's user avatar
3 votes

Executing functions after multiple data sources have been loaded in Leaflet AJAX

According to the docs there is a function L.Util.ajax that returns a promise. So this should work (is untested) data_layer1=L.Util.ajax(data1.geojson,{options}); data_layer2=L.Util.ajax(data2.geojson,...
Dataform's user avatar
  • 1,356
3 votes
Accepted

Displaying nonspatial data via spatial data in Leaflet

In your globalArrayJobsCID, you just push the cid, not the associated value. And I guess you actually want to show that value (i.e. an item from your data), not the cid itself (or not only that). ...
ghybs's user avatar
  • 7,233
3 votes

"Unsupported GeoJSON type" from AJAX request to PostGIS database

JavaScript will not wait for the ajax call to return before continuing processing your code. The only thing that will happen once the Ajax call is completed is success: function (resJ) { res = JSON....
JGH's user avatar
  • 42.5k
2 votes

GeoJSON interaction with leaflet

I think it is a asynchronous issue: your function $.getJSON does not ends before the remainder of the code is executed. Therefore, the object people actually doesn't exist when your code want to use ...
juminet's user avatar
  • 1,285
2 votes
Accepted

Collect external geojson from user and pass to L.GeoJSON.AJAX()

Your "working" Pen has unassigned qom variable, and L.GeoJSON.AJAX('#loadButton') is definitely not going to work, as '#loadButton' URL will not provide a valid JSON data. The thing you must ...
ghybs's user avatar
  • 7,233
2 votes

Add multiple WFS layers to Leaflet map from GeoServer using JQuery Ajax calls

It turns out that I think JQuery is re-using the callback function name "getJson". To avoid this, I create callback function names for each layer using the actual GeoServer layer name. My layer ...
firsttube's user avatar
2 votes
Accepted

Leaflet create marker from ajax call data

Most probably your data is still string type, which is not suitable as input to Leaflet Marker factory L.marker. From your code and data sample, jQuery $.get performs an AJAX request and treats the ...
ghybs's user avatar
  • 7,233
2 votes

How can I show a popup in a map, using Leaflet?

Here is a working example, for points. I used JQuery to get the data from my external GeoJSON file. Note You need it running from a server or localhost if your using an external data file. In this ...
Bill Chappell's user avatar
2 votes
Accepted

Displaying geojson polygon in leaflet imported with ajax

It turns out my problem was related to Configuring Cross-Origin Resource Sharing (CORS)on the Google Cloud bucket. I needed to add the domains that hosted my source geojson file. I used this ...
user2059737's user avatar
2 votes

Generate and add L.control.layers from GeoJson properties to Leaflet

You're creating new markers right here: overlays[destination] = new L.GeoJSON(null, { Just don't. Refer to the existing instances instead.
IvanSanchez's user avatar
  • 10.3k
2 votes

Searches by area names in OpenLayers with request of AJAX in the PostGIS database

Try something like this: var feature = yourVectorSource.forEachFeature(function(feature) { if (feature.get('id_teren') == id_teren) return feature; }); if (feature) { feature.setStyle(...
Mike's user avatar
  • 12.7k
2 votes
Accepted

Load data from URL to update Billboard position Cesium

For anybody who might be having an issue similar to me i have found a solution based on a tutorial from https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Picking.html. My solution based on ...
Owen's user avatar
  • 63
2 votes
Accepted

Executing functions after multiple data sources have been loaded in Leaflet AJAX

One possibility would be to use setTimeout function to check when all three layers are loaded, something like this: var layer1Loaded = false; var layer2Loaded = false; var layer3Loaded = false; ...
TomazicM's user avatar
  • 26.5k
2 votes
Accepted

Heatmap with GeoJSON, Leaflet and Leaflet.heat plugin

Instead of GeoJSON object you are passing Leaflet layer as first parameter to geoJson2heat function (see https://geomappando.com/2016/11/08/come-realizzare-una-heatmap-con-leafletjs/). You don't need ...
TomazicM's user avatar
  • 26.5k
2 votes

Leaflet Feature bindpopup does not display (OnEachFeature)

Instead of using the L.GeoJSON.AJAX method of loading in my data, I have opted to use $.getJSON as shown here. I was able to then load the popup at a later line using L.geoJSON and add my '...
KullideDev's user avatar
2 votes
Accepted

Leaflet Feature bindpopup does not display (OnEachFeature)

L.GeoJSON.AJAX object is an extension of Leaflet L.GeoJSON object and so it inherits all it's options (this is not explicitly mentioned in leaflet-ajax plugin docs). This means it's possible to use ...
TomazicM's user avatar
  • 26.5k
2 votes
Accepted

How to tie an ArcGIS Server QueryTask result back to the calling layer?

You can do this by sending the LayerName along with the QueryTask to a separate function. for (layerDef in config){ var queryTask = new QueryTask({url: config[layerDef].url}); var query = new ...
OGmaps's user avatar
  • 734
2 votes
Accepted

Popup for each feature when using Leaflet marker.cluster plugin

If you want to have popup for each layer, you have bind it to each individual layer, not to the cluster: var my_data = new L.GeoJSON.AJAX("http://127.0.0.1:8000/my_data/",{ onEachFeature: ...
TomazicM's user avatar
  • 26.5k
2 votes

Problem with put sld in geoserver

Your SLD input file is invalid - there is no Stroke element for TextSymbolizers so GeoServer discards those elements when it parses your input file to convert it into a style. The "extra" ...
Ian Turton's user avatar
  • 82.6k
2 votes
Accepted

General JavaScript function handling popups of various JSON layers in a Leaflet map

There are several things wrong in your approach. First thing that is wrong is that comparison in JS uses == or ===, single = is used for assignment. Second thing that is wrong is the way you define ...
TomazicM's user avatar
  • 26.5k
2 votes

Converting from esoteric coordinate systems to EPSG:4326 WGS 84

The EPSG:3081 NAD83 / Texas State Mapping System is supported by MyGeodata Cloud Converter so you can upload your Shapefile there, set EPSG:3081 as input coordinate system (if it is not recognized ...
Tonny's user avatar
  • 555
2 votes
Accepted

Multiple WFS layers in Leaflet, loaded with Ajax with bounding box, do not display correctly

There are three things you have to take care of to make it work. The main thing is using different name for each jasonp callback when retrieving WFS data. Since calls to get WFS data are async, when ...
TomazicM's user avatar
  • 26.5k
2 votes

Can't get OpenLayers vector layer to display (loaded by AJAX)

Resolved... the problem is where the projections are defined. When using loader, the geojson reader needs this: var features = geoJsonFormat.readFeatures(data, { ...
user44021's user avatar
2 votes

AJAX calls for leaflet

Two things have to be corrected in the above code. ArcGIS service for UNESCO sites returns geometries as points, so you have one dimension to many when getting site coordinates. It should be: var lon =...
TomazicM's user avatar
  • 26.5k

Only top scored, non community-wiki answers of a minimum length are eligible