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


5

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

You can do it now, as of version 0.7 there is an additional option called 'maxNativeZoom' after which it will interpolate tiles. Here's a link to the documentation: http://leafletjs.com/reference.html#tilelayer Here's the info: minZoom Number 0 Minimum zoom number. maxZoom Number 18 Maximum zoom number. maxNativeZoom Number null Maximum zoom ...


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

Change the order of your js-files. Load OpenLayers before the files within js-folder. <script src="ol-211/OpenLayers.js"></script> <script src="ol-211/firebug.js"></script> <script type="text/javascript" src="js/geocoding.js"></script> <script type="text/javascript" src="js/map1.js"></script> <script ...


4

I have written down a small piece of code might be helpful for you. You can try working example on jsFiddle <!DOCTYPE html> <html> <head> <title>Leaflet - Marker Click Event</title> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" ...


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

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

Set the center of the map to the airplane position after it has refreshed. OpenLayers setCenter


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

You can use this for creating dynamic colors var color; var r = Math.floor(Math.random() * 255); var g = Math.floor(Math.random() * 255); var b = Math.floor(Math.random() * 255); color= "rgb("+r+" ,"+g+","+ b+")"; then use this var firstpolyline = new L.Polyline(pointsSelection, { color: color, weight: 5, smoothFactor: 1 }); I think this ...


3

I don't know what happened anyone with greater knowledge can explain but for anyone with similar problem I solved it by adding controls: // Panel (toolbar) var oDragPanCtrl = new OpenLayers.Control.DragPan({ isDefault: true, title: 'Pan map: keep the left mouse button pressed to drag the map' }); var oZoomBoxOutCtrl = new ...


3

You may have already done these, but I have found they help a lot from my experience. Doing away with trailing (extraneous) decimals could also trim quite a bit of fat off of your json. Depending on your needs, you could go down to 2 or 3 decimal places. This all depends on scale of your map and the level of accuracy you are needing. Removing white space ...


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'; }



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