Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

3

Since there seems to be no official hook to implement this, one has to resort to hack. L.Draw.Marker class has internal _onClick method which is called when user clicks with mouse to create marker. This method can be replace with our own hacked method by modifying L.Draw.Marker class. We can check here if clicked point is within polygon and allow creation ...


2

Problem solved with method map.latLngToContainerPoint(); applied on the points(p1 and p2). I had to convert geographical to the pixel coordinates. Thanks to the TomazicM comment :)


2

The solution to this was z-index related and after finding a thread on the Leaflet Github I came across that mentioned this but was not in the included options was to do this. Added zIndex: 100, To my WMS tile layer like so... var radar_current = L.tileLayer.wms("http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0q.cgi", { layers: 'nexrad-n0q-...


2

Set scrollWheelZoom option to 'center' when defining map: var mymap = L.map('spotmap', { dragging: false, scrollWheelZoom: 'center' }).setView(spot_LatLng, 18);


2

In your nonworking fiddle you are using version 1.4.0 of leaflet.js, but version 0.7.2 of leaflet.css. I tried with correct version of CSS and it works OK.


2

leaflet requires vector layers to be in WGS84 coordinates. Your shapefile is not in WGS84 coordinates. Transform to WGS84 coordinates with: SCMP_trans = spTransform(SheridanCountyMTParcelShapes,CRS("+init=epsg:4326")) Test leaflet outside of shiny with: leaflet(SCMP_trans) %>% addTiles() %>% addPolygons()


1

I'd recommend something like the following: var colors = { orange: '#ffa500', blue: '#0000ff', green: '#008000', pink: '#ffc0cb', }; var markerOptions = { opacity: 1, }; switch(Data[i].value) { case "A": markerOptions.color = colors.orange; break; case "B": ...


1

Below is one possible solution using Turf library. Solution is not exact since Turf does not have method to split polygon with line and get as result two split polygons. The closest method is turf.difference(poly1, poly2), which cuts out second polygon from first. If second polygon is very thin and long rectangle (line with small 'height'), this can be used ...


1

You could achieve what you want by adding custom property myID (could be any name) to marker and setting it to index value i. In this way the correct index to data array will be available at click event. Something like this: for(i in data) { var title = data[i].title, id = data[i].id, position = data[i].position, kriteria = data[...


1

Here is the basic idea, set a style for the line, and set a style for the highlight, then in your forEachFeature function, set the layer on click to highlight. My example below resets the style in case, you clicked on one before. var highlight = { 'fillColor': 'yellow', 'weight': 2, 'opacity': 1 }; function forEachFeature(feature, layer) { ...


1

One possibility would be to use Leaflet's L.CRS.Simple flat (Cartesian) CRS. Here one pixel corresponds to one map unit. Let's say we want map units that correspond to original rasters map pixels (before it was cut to tiles): one map unit is one pixel on original raster. With tile layer at zoom level 0 whole map is within 256 x 256 pixels, so factor for ...


1

Two examples that might apply: https://github.com/chillly/Leaflet-Toads no longer an active demo site but the code shows you how to get the extents and through an ajax call, get the toads (points) in the current extents, and on change drop them and get the new points. Basically, you would also drop your table and repopulate with the point attributes. https:...


1

I would use leaflet ajax instead of using the django tempalate to return your geospatial features. https://github.com/calvinmetcalf/leaflet-ajax. Download this code, save it to your django static folder and in your index.html you need to reference it. <script type="text/javascript" src="{% static 'dist/leaflet.ajax.js' %}" > </script> for ...


1

Sounds like you want to read a file and create markers, and these markers should be in a layergroup so Leaflet handles them as one layer. Here is something similar to your code that I used. $.getJSON(url, function(data) { for (i = 0; i < data.length; i++) { var lng = data[i].coordinates[0]; var lat = data[i].coordinates[1]; ...


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