New answers tagged

0

There's also this jsfiddle I stumbled upon. I can't claim it as my own but you can sort through the options objects via event.target.options or even set the color attribute for a target event via event.target.setAttribute()


0

If you're geojson file has something like: var kcTracts = { "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": {}, "geometry": { "type": "Polygon", "coordinates": [ [ [ -109.3359375, 42.032974332441405 ], [ ...


0

Checkout turf.js isobands function. Though ultimately @Diffusion_net is right: trying to do this in the browser is going to be much harder than doing it on your own using Arc/qGIS. If your data is relatively static, this shouldn't be an issue. If you have to perform these calculations on the fly in the browser, then isobands should get you there.


0

If you use latest MapTiler version from http://www.maptiler.com/ to generate the tiles, it will directly produce for you an ready to use openlayers.html viewer. You clearly use a very old version of MapTiler - as the viewer you show here is based on the old OpenLayers (v2) and the XML file is not anymore generated by recent MapTiler versions. Instead, there ...


0

See the Readme about GeoJSON properties. The correct property name is height, not building:levels. building:levels is the corresponding tag in the OSM database but it is converted to a height property for the resulting GeoJSON data.


0

I would suggest that you have a look at this Example: WMS Note the following code: new ol.layer.Tile({ extent: [-13884991, 2870341, -7455066, 6338219], source: new ol.source.TileWMS({ url: 'http://demo.boundlessgeo.com/geoserver/wms', params: {'LAYERS': 'topp:states', 'TILED': true}, serverType: 'geoserver' }) }...


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 ...


0

So I do not know of any native plug ins for leaflet to create contour lines and fill them in like this. So unless you want to write your own function for achieving this I see the easiest way to go about this would be to create contour polygons(filled contour lines) in a desktop software (ArcGIS, QGIS, etc.)and export the shapefile, afterwards convert that ...


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


0

For points you can do it using CSS, in the layer you can use the pointToLayer function and return a DivIcon with the CSS class you want. Then the CSS has the rotation applied. See http://davetimmins.com/2015/10/07/Rotated-icons-with-leaflet/ for more details.


0

MapCentia.gc2.map is referencing the OpenLayers map object. So just switch it out with Heron.App.map.


0

L.LayerGroup can contain other LayerGroups, pretty confusing. I made this generic solution for recursively traversing a layergroup in my app ('vg.Map.' are just namespaces): /* vg.Map.recurseLayerGroup Run recursively through L.LayerGroup until contained layers are no longer instances of L.LayerGroup, then execute callback function. Parameters:...


0

It is possible to convert to shapefile in JavaScript, in the client side. The following library accomplishes this. Perhaps it is outdated (2012-2013), but at least it shows the concept. JS2Shapefile JS2Shapefile is a Javascript class to create ESRI shapefiles directly in the browser. It also includes a couple of helper classes for creating and ...


0

Short answer: Avoid the OpenLayers Plugin. The plugin has only got few bugfixes lately, but no active development. As an alternative, try the new QuickMapServices plugin. For license reasons, it does not contain Google Maps by default. But you can activate them with Web -> QuickMapServices -> Settings -> More Sevices -> Get contributed pack.


0

<html> <head> <meta charset=utf-8 /> <title>PipeGeoJSON Demo</title> <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> <script src="https://api.mapbox.com/mapbox.js/v2.2.4/mapbox.js"></script> <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <...


0

This error is caused by having jquery/jqueryUI loading at the same time from Esri's Dojo configuration and in our script. Per the thread here, putting the Esri script at the bottom of the page after jQuery was done loading removed the error and got everything working.


0

My answer to this earlier question has a code example of how to accomplish this: http://gis.stackexchange.com/a/199366/72254


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 ...


0

This was problem of leaflet crashing when it had to draw many features. i called the map.fitbounds after 1 sec and it worked.


0

So I've solved this with a Javascript prompt by using the following code: interaction.on('drawend', function(e) { //pass an attribute to the feature var myAttrValue = prompt("Enter Attribute", ""); var myFeature= e.feature; if (myAttrValue != null) { myFeature.set('column', myAttrValue); } pointWFS('insert',myFeature); });


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

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. ...


0

I think this project may helps you. https://github.com/highsource/ogc-schemas. It is based on Node.js environment. but if you want to make use of it in client side, it is possible with Browserify(http://browserify.org/)


0

I got an answer on Geonet, thanks to Yusuf Ali! Step 1, hide deleting: .deleteAttachment{display:none;} Step 2, prevent adding new attachments: dojo.query('> div > form', dojo.byId("attachment-editor-container")).style('display', 'none'); Step 3, hide parentheses left after hiding the delete icons: var spans = dojo.query('> div > span &...


0

The latest version as of writing is 3.16.0, has the API: ol.extent.containsXY(extent, x, y) See more info in the latest API docs


0

It might have to do with your getlatlong() function. I would try to troubleshoot by first replacing coordinates: getlatlong(feature.properties.x, feature.properties.y) with [1,1] or some other simple known X and Y. If that works then your issue is with this. If not you've ruled that out. I don't see anything misspelled or punctuation missing so after that I ...


0

With Visual Studio code, if you have TypeScript definitions files for certain libraries, /// <reference-ing such a definition file will light up intellisense for that particular library in any JS/TypeScript file that has that reference tag. For this to work in the case of leaflet, you need node.js installed and then. Make sure typings is installed npm ...


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?


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')....


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, ...


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 *...


0

Your code above works great without the <script> tag once its removed, like so: var this_marker = L.marker([51.5, -0.09]).addTo(mymap).bindPopup ('<div style="color: red">Hello<br>world</div>').openPopup(); If you are trying to add in additional JavaScript functionality to the popup when its open you could use a selector such as: ...


0

Turns out it got solved by setting the projection to EPSG 3857


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]


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() ...


0

It appears that Derek's answer above no longer works at version 3.16 of the JS API. An update came from Kelly Hutchins at Esri, and is to add the custom basemap to esri/basemaps as shown at https://developers.arcgis.com/javascript/3/jsapi/esri.basemaps-amd.html require([ "esri/basemaps", "esri/map", "dojo/domReady!" ], function (esriBasemaps, ...


0

This is a follow up answer. The quick way to do it is to use a listener event and extract values for each polygon using event.feature.H.ATTRIBUTE_FIELD; So, in my case it ended up as the following? Cities.addListener('click', function(event) { var str = event.feature.H.NAME; infowindow.setContent(str); infowindow.setPosition(event.LatLng()...


0

Have you tried either of the printing solutions listed here? http://leafletjs.com/plugins.html#printexport


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 ...


0

In your "working" code, you are missing the argument in teststyle() call. That may be just a typo? I guess you meant just teststyle (without parenthesis), i.e. just pass a reference to the function, not to its result after execution. In your example code, the teststyle function expects a feature (typically from an L.geoJson layer group) in order to read its ...


0

Based on the error, it appears that there is an issue with the variable type or referencing the variable. You may want to see this SO Q&A: JavaScript - Uncaught TypeError: Cannot read property 'search' of undefined The OP was able to troubleshoot based on one of the answers and found that using string() instead of toString() worked for them. i ...


0

If you have created the feature layer on the client side (no server side url), then you cannot use a query with a where clause. I was able to work around this by searching the extent of the map and then deleting all the items that I found. For example: function removeAllLayerFeatures(map, layer) { require(['esri/tasks/query', 'esri/layers/FeatureLayer'],...


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!


0

This should work. var yourString = '0.0,0.0,0.0,0.0,0.0,0.0'; var string = yourString.split(','); // Create array of float for each pair of coordinate var a = string.length; for (i = 0; i < a; i++) { string[i] = parseFloat(string[i]); } // Initialize an array to store the new values var b = string.length / 2; var array = []; for (i = 0; i < b; ...


0

I figured it out, solution would be to get bounds coords from pixels: map.getCoordinateFromPixel([x,y]);


0

match(/\d{2}[A-Z]{3}\d{10}/gi) \d{2} digits (0-9) (2 times) [A-Z]{3} any character of: 'A' to 'Z' (3 times) \d{10} digits (0-9) (10 times) /gi ignore case


0

Changing layer on zoom: Since you did not mention what tool you will use (Google Maps, Leaflet, ...) I will try to answer your question with pseudo-code. The principle of changing the layer when zooming is easy. You have different possibilities how to solve this. The simplest way of doing this is by "assigning" layers to zoom levels. This could look as ...


0

After many tedious and failed attempts at trying to figure this out, I finally got it figured out. Since the AttributeTable is an off panel widget, it is opened in a different way than on panel widgets. Inside the AttributeTable widget.js file, the open method invokes this._openTable(). Since my custom widget.js file also contains the open function, I ...


0

This was added as a new feature in Leaflet just a few days ago. That feature will be part of the v1.0.0-rc2 release. Also, your method works well, as demonstrated here.



Top 50 recent answers are included