Tag Info

Hot answers tagged

12

If you are interested in an implementation look at jsts a Javascript implementation of the much used Java Topology Suite library -- depending on whether you prefer reading Javascript or Java, I suppose. A general idea of how the algorithm works. For points, it is trivial, you simply buffer them by a given radius. If you have multiple points, you will have ...


8

There's a lot of subjectivity still in play, but I think a broad answer to your question is that it's getting easier every day to use GeoJSON directly in a leaflet map without tiling, and this is ultimately a good direction for interactive maps to be going. As such I tend to build maps using your third option above. That comes with a few caveats. You ...


6

You can use jquery Ajax to load data and then add it. var district_boundary = new L.geoJson(); district_boundary.addTo(map); $.ajax({ dataType: "json", url: "data/district.geojson", success: function(data) { $(data.features).each(function(key, data) { district_boundary.addData(data); }); } }).error(function() {}); or You can use ...


5

I am not sure if I completely understand what your application is doing. Are you sending a query to postGIS every time the bbox changes and then render the response as a vector layer? If that's the case, in my experience, there are no obvious solutions to the problem. No magic bullets yet, but still solutions can be found, here some ideas: Maybe not what ...


5

I think that your are thinking it is more complex than you think! Try this: var popLocation= new L.LatLng(-42.8585,147.2468); var popup = L.popup() .setLatLng(popLocation) .setContent('<p>Hello world!<br />This is a nice popup.</p>') .openOn(map); Sourced from the excellent documentation. I know what you want to do now. ...


5

You can get it with JSTS. Check DistanceOp.js.


5

Your units are in decimal degrees and they should be in a projected coordinate system. If you still have the gps unit, you can change it to something like an appropriate UTM projection then download the coordinates and use those in your calculation.


5

It's simple: create L.Map with scrollWheelZoom: false option, then add a listener: map.once('focus', function() { map.scrollWheelZoom.enable(); });


5

If you have GeoJson that looks like that on the wikipedia page var json={ "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": { "type": "Point", "coordinates": [102.0, 0.6] }, "properties": { "prop0": "value0" } }, { "type": "Feature", "geometry": { "type": "LineString", ...


4

This is a pure Javascript api that performs Dissolve, also commonly called Union, and other spatial operations. It is based on Java Topology Suite. jsts


4

Since your search region is circular, it is perhaps best not to consider it to be a polygon, but as a point with a radius and to use the ST_DWithin() function: ST_DWithin — Returns true if the geometries are within the specified distance of one another. It should save you and the processor a lot of effort.


4

I think there is no better way than to handle zoomend event. To group markers by zoom levels, use L.LayerGroup: turning them on and off will be easier. Calling map.removeLayer() or map.addLayer() twice won't produce any errors or add a layer twice: there is an internal hash that prevents such things. So you can just have a bunch of if (zoom > 6 ...


4

You forgot to add Leaflet CSS: <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" /> Also there are numerous typos in your code: for example, in html, body{} stylesheet line. Do check for them before deploying to production.


4

Echoing Bill: it depends. I would say never/rarely do the second option. Keep your data and styling separate. The first and third options might be rephrased as "when should I use a service to render map features?" and "when should I use Leaflet to render map features in-browser?" For me, I try to do the third option whenever I can. Rendering features in ...


4

The OpenLayers.Control documentation says: Controls by default are added to the map they are contained within however it is possible to add a control to an external div by passing the div in the options parameter. So you just need to pass the div to the control while initialising it, somewhat like this: var mp=new ...


3

Look into Leaflet-Ajax. It streamlines everything. Will give up-vote for Neogeomat for mentioning it. Get the script here and add it to your header: <script src="/js/leaflet-0.7.2/leaflet.ajax.min.js"></script> Then it's a matter of uploading with the file p name. var geojsonLayer = new L.GeoJSON.AJAX("foo.geojson"); ...


3

Just to add for future reference, I got JSTS to work with Leaflet.js by exporting / importing GeoJSON between the two libraries. It's obviously not very efficient if you're doing a lot of processing but for simple one off conversions it's a pretty straightforward solution. function buffer(leafletGeometry, distance){ var reader = new ...


3

Here you go. You just call the update method on the outside div, not the L.control element. I used JQuery for easier selection of the div.


3

Well, if you've got a table that natively (sorted by FID or ObjectID as applicable) is NOT sorted how you want it, and you want to view the table sorted by a specific field(s) with a unique ID field in order of the sort, you don't need to mess with any scripting at all. Just use the SORT geoprocessing tool that is included in ArcGIS (In ArcToolbox > Data ...


3

I'm not sure if this is the right way to do it, but there is a spatialreferences attribute of the WMSLayer object that contains a list of numbers that represent what to request from the backing server. If you insert 900913 as the first element: var wmsService = new WMSLayer(wmsAddress, { resourceInfo: { extent: extent, layerInfos: [new ...


3

Okay, maybe a bit ugly but I put a lot of functionality in here http://bl.ocks.org/andrewxhill/9003528 It includes create an initial layer on the fly a hover to the layer after timeout, changing the size of the density grid recalculating a style to go along with the new size I think it will get you pretty far. Note, you could make the style ...


3

It's not possible to change SQL or CartoCSS of a visualization with private data. The reason is pretty clear: if we allow to change SQL any user could read somehow your data. So to cover your use case we introduced the concept of template maps. That allow you to create maps with hidden sql and cartocss but with some configurable parameters. Basically it ...


3

Ok. Finally with doing some tests I was able to figure out where the problem was. KML structure does not have a Featurecollection type in its structure like the one that GeoJSON has. Instead, all you need to do is to store each feature in a separate placemark tag. This means that KML does not support multiple feature information in one placemark tag (which ...


3

Figured it out function FindLabel ( [NAME] ) { return [NAME]+'\nNational Forest'; }


3

You will need to add a new interaction. Assuming that... this.mapRaster = ol.Map This should work this.mapRaster.on('singleclick',function(e){ var iconFeature = new ol.Feature({ geometry: new ol.geom.Point(e.coordinate), }); iconFeature.setStyle(_self.iconStyle); _self.rasterVectorSource.addFeatures([iconFeature]); Make the ...


3

Lines and polygons can be drawn in Leaflet either by the user of the application with Leaflet Draw Or programmatically, with geojson - or other leaflet or mapbox classes For distances and length you might look into Leaflet GeometryUtil And you can calculate the area of a polygon with geojson-area


3

This is already documented here. There are two undocumented tileerror events for the layer When a single tile is missing it trigger the event “loadwarning” to indicate that something is wrong with this layer. When all the tiles in a layer are missing it trigger the event “loadfail”. There is also some additional documentation in the code here UPDATE ...


3

Yes with Data Streaming the KML - See 'Stream KML Google Maps' [fmeserver.com/userweb/sharper/playground/index.html] var ctaLayer = new google.maps.KmlLayer('http://fmeserver.com:80/fmedatastreaming/Samples/austinApartments.fmw?'); is doing the request on the page request (on first load or refresh) FME Server is running the workspace and delivering the ...


3

The map object will take on the projection of the first layer you add to it, in the case of your code, the streets basemap is 102100 (web mercator). You have two options to solve this: Use your own basemap service that is in your 102726 projection so that the points from the web service show up in the correct place. Stick with arcgis online basemaps, ...


3

You are providing html in setContent() var popup = L.popup(); function onMapClick(e) { popup .setLatLng(e.latlng) .setContent(e.latlng.toString() + '<a href="http://www.google.com">Visit Google</a>"') .openOn(map); } map.on('click', onMapClick);



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