Hot answers tagged

3

Your code is a bit complicated concering your callback:loadFeatures function. Within the function you add features for both requests to both sources. Try to distinguis them using two separate functions and see if this is your case. var geojsonFormat = new ol.format.GeoJSON(); var vectorSource = new ol.source.Vector({ loader: function(extent, resolution, ...


3

If you already have a GeoServer WMS service, then the most straightforward way is to use the getFeatureInfo capabilities of the WMS protocol. See https://github.com/heigeo/leaflet.wms and http://docs.geoserver.org/latest/en/user/services/wms/reference.html#wms-getfeatureinfo


2

You could use the CartoDB SQL API with CartoDB.js to call the data that you want to display depending on where the user click. In this section of the CartoDB documentation you can find more information about using theCartoDB SQL API within CartoDB.js. In this example you can find how a buffer is created everytime that a user clicks on the map and the points ...


2

Your data is stored in the features array. You can access that by specifying a custom datasource within the ajax property like this: "dataSrc": "features". I haven't found a way to get the GeoJSON property "type": "FeatureCollection" that way, it is outside of the actual data "rows". The complete code: $(document).ready(function() { $('#example')....


2

I found the simplest way to restrict the maxZoom levels for a XYZ layer was to override the getNumZoomLevels method: function zoomChanged() { var coor_from = new OpenLayers.Projection("EPSG:4326"); var coor_to = new OpenLayers.Projection("EPSG:900913"); var level = map.getZoom(); var center = map.getCenter() ...


1

you want to create a layer with a single feature so you must use: features: [features[0]]


1

OSM Draw Feature <link rel="stylesheet" href="../theme/default/style.css" type="text/css"> <link rel="stylesheet" href="style.css" type="text/css"></head> <style type="text/css"> #controlToggle li { list-style: none; } p { width: 512px; } /* avoid pink tiles *...


1

Add an ol.interaction.Select to your map. It allows multi-selects (shift+click), and sends an array of selected and deselected features in its 'select' event. It uses an ol.Collection to store selection results. For instance: var int_select = new ol.interaction.Select({ features: new ol.Collection(); }); map.addInteraction(int_select); int_select.on('...


1

No standard solution, you should get the position and id's of your features and bind something like this: function openInfowindow(layer, latlng, cartodb_id) { layer.trigger('featureClick', null, latlng, null, { cartodb_id: cartodb_id}, 0); } as is shown here on this block. You should build your own infowindow and disable JavaScript sanitization on it so ...


1

In your second code snippet, you're using the style option for L.GeoJSON as if it were an valid option for L.CircleMarker. Read the documentation carefully again and ask yourself: Does L.CircleMarker use a style option? A better way would be to calculate styles inside pointToLayer, e.g.: var layer = L.geoJson(data, { pointToLayer: function(feat, ll) { ...


1

Limited success, but following seems to give at least some intellisense ... add a _references.js to the Visual Studio solution add a copy of the leaflet-src.js make sure the _references.js has /// <reference path="leaflet-src.js" /> in it But it's not 100%, so anything better?


1

SOLVED: when using a custom image as a marker, adjust the anchor in the proper way. In my case I was using anchor: [0.5, 46]. I just replaced 46 with 33, so anchor: [0.5, 33]


1

This is a classic script tag order issue. Make sure you load the Leaflet library (and possibly the Mapbox one too) before the associated plugins. Otherwise, the latter will not be able to find Leaflet definition and do their work. When your issue is very programming-related, feel free to ask on Stack Overflow, you would probably receive an answer much more ...


1

Hi Luffydude as weird as it seems you get the same errors I had on my last project a couple of weeks ago, so this is how I worked it around: 1- the geometry column not being inserted means that you need to specify it in the feature you are sending in WFS-T request, so before you do this formatWFS.writeTransaction([f],null,null,formatGML); add the ...


1

Turns out the answer was that Geoserver didn't allow for jsonp to be shown in web applications. After I asked the web dev responsible for dealing with servers he was able to write a few lines of code to the server and now my layers suddenly all work in the web apps!


1

I'd use the OpenLayers Format readers and writers. GML reader here http://dev.openlayers.org/apidocs/files/OpenLayers/Format/GML-js.html GeoJSON writer here http://dev.openlayers.org/apidocs/files/OpenLayers/Format/GeoJSON-js.html May be overkill to just convert from GML to GeoJSON, but OpenLayers API are widely used and tested, and also easy to extend. ...



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