Tag Info

New answers tagged

1

Figured it out thanks to some documentation reading. The polygon in leaflet responds to setStyle but the marker can be changed using setIcon Documentation for setIcon


1

Seems like you can't do that because a marker uses an image to render. I think you'd need to grab the icon class of your marker and change the "iconUrl" attribute to whatever new image you want. Source: Leaflet API Reference Hope that helps, DR


0

Sorry for the late reply but there is also the leaflet-vector-layers plugin which has support for postGIS services http://jasonsanford.github.io/leaflet-vector-layers/demos/postgis-restful-web-service-framework/ By the looks of it you can filter the service. I've used this plugin for ArcGIS services and it's been really good. Hope that helps, Rowan


0

Depending on how confident you are with technical setups, rather than running local GeoServers, you could use something like TileMill to generate MBTiles files of all your images, or just the images using Invar. This can then be show by simple python code like TileStache. This would be a much lighter weight setup.


0

If its a one time query and you don't have more than 1000 features try pasting this into qgis by using the add vector layer - choose protocol and replace this arcgis rest URL with yours: http://geodata.epa.gov/arcgis/rest/services/OAR/USEPA_NEI_2005/MapServer/1/query?where=objectid+%3D+objectid&outfields=*&f=json ... This assumes you have gdal 1.10 ...


1

For the satellite tiles, you could render them yourself using Mapnik. Landsat and NAIP are two sources of free satellite raster data. edit: I've also just come across a growing dataset (also free) of High Resolution Orthoimagery, which I've never used, but is much higher detail than the other two sources.


1

For a one-time conversion I would have used the accepted answer from @Sasa Ivetic but needed something real-time, and Terraformer worked decently for that. Unfortunately it's only for single features by default, so for multiple features you need to loop through the array and add an ID to each feature: var FeatureCollection = { type: "FeatureCollection", ...


2

Your approach looks ok to me. On my local system, I skipped the TileCache part. Mapnik fills the folders in the way Openlayers reads them from disk using file:///... I don't know if leaflet can do it the same way. For the satellite tiles: You have no chance to get them legally. Google and bing do not like storing their tiles locally. If you have ...


1

The quickest way to do this is https://mangomap.com, you should be able to get the whole thing set up in about 10 minutes without writing a single line of code. I'm the CEO, just give me a ping on chris@mangomap.com if you have any questions.


-1

Ok, my assumptions in 2 were incorrect. You can use mapbox.js. The end result will be a bit different, I believe - the markers themselves will be a static raster layer, but they'll be clickable. The spec that makes large scale interactivity work is https://github.com/mapbox/utfgrid-spec It's implemented clientside in ...


0

I'm not sure this is the appropriate answer, but I wanted to point out that setting up the proxying in nginx is very easy. Let's say Geoserver is running on port 8080, and your web server (nginx) is running on port 80. It's as simple as adding: location /geoserver { proxy_set_header Host $http_host; proxy_pass http://127.0.0.1:8080; } to your ...


0

the math will depend on the projection and what you want to preserve. A generic solution would consist in computing the Lat/Long coordinates of your points, then you simply add the value of your shift to each coordinates, and you finally reproject in your initial projected coordinate system. For pure East-West rotation, there is no distortion. For ...


1

Short answer The containerPoint methods date from a feature request back in 2012, and today, they're a bit confusing. The best answer is Leaflet maintainer Vladimir Agafonkin's description: "layerPoint is actually a point relative to the map layer (the div which contains tiles and markers), not the outer map container. What you need is ...


0

What's the network tab in your browser tools telling you? Is it requesting tiles from a server? Is it returning an error message? Did you set the tile_layer parameter to something valid in your rails app before rendering to HTML? For example, http://{s}.tile.osm.org/{z}/{x}/{y}.png?


0

It's a bit high time I answered, but here goes: Since the use of Wax is deprecated as you mentioned, here are some Mapbox examples to get you started. Bear in mind that the Leaflet API is embedded into Mapbox.js and can be used hand in hand with Mapbox code. Using http://localhost:8000/{z}/{x}/{y}.png means to store the tiles in your own folder. This is ...


1

Hey plain CSS did the trick: .leaflet-container { background-color:rgba(255,0,0,0.0); }


1

An alternative solution to that is to stop event propagation with JavaScript (like it's done for Leaflet controls, e.g. zoom buttons): var div = L.DomUtil.get('div_id'); if (!L.Browser.touch) { L.DomEvent.disableClickPropagation(div); L.DomEvent.on(div, 'mousewheel', L.DomEvent.stopPropagation); } else { L.DomEvent.on(div, 'click', ...


3

There is a plugin for that: Leaflet.Terminator.


2

Did you find a solution? I've created a function which does this for me. function mapToPosition(position){ lon = position.coords.longitude; lat = position.coords.latitude; var marker = new L.Marker([lat,lon],{title: "Not at the right spot? Drag me!"}).addTo(map); marker.dragging.enable(); marker.on('dragend', function(e){ var ...


2

No, you don't need a special apache module. You don't even need a webserver at all because you can just to open file:///C:/Profiles/ApachePHP/apache/www/mwork/maperitive_test1/index_leaf.html in your browser. The problem is your osmUrl. Either you have to make C:\Profiles\Maperitive\Tiles available through your webserver. Or you have to replace the URL with ...


1

Using the example from the Leaflet website, note where the L.Control object is instantiated as info; this is the <div> box in the upper-right associated with the map's hover interaction. Here is where it is defined in index.html from the Leaflet example: // control that shows state info on hover var info = L.control(); info.onAdd = ...


1

You need to set the desired basemap as: var basemap = L.Tilelayer (drop "new")... They're all being added as overlay layers as is


0

This is less of a Leaflet issue than a CartoDB one. In your code you are adding a CartoDB layer to your Leaflet map, then interacting with CartoDB to filter the features the layer shows. The short answer is: you need to ask CartoDB for the bounds. Leaflet doesn't know much about the CartoDB layer, especially when it comes to the features CartoDB is showing. ...


0

We had similar problem in one of our projects.We've used open layers 2 modify feature (http://openlayers.org/dev/examples/modify-feature.html) to implement editing topology and it works quite well.You can implement some simple basic checks on the client side (open layer have a good support for working with geometries), but we've decided to do most of them on ...


0

I'm not aware of a plugin that lets you do this right now, but it could be handy! In the meantime, I'd recommend looking into using Leaflet and Leaflet.draw. My process for doing this would be: Load the geometry that a user is editing into the Leaflet.draw layer. P Listen for draw:created, draw:edited, and draw:deleted. Push changes to CartoDB as GeoJSON ...


2

The controls on the map appear to be OpenLayers. Here's how you can find out yourself what kind of data it's using in the client in Chrome or Firefox: In Chrome, go to Menu > Tools > Developer Tools and switch to the Network tab. In Firefox, go to Menu > Developer > Network Refresh the page, pan around the map a few times, see what resources load.


2

It does really depend on the project and what type of data you're using (and what you know how to use) but Tom Macwright made this handy simple Map Makers cheat sheet: https://github.com/tmcw/mapmakers-cheatsheet


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


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


0

If you just want to limit the layers from showing beyond a certain point, you could apply scale dependency to the layer by using code similar to below that gets run each time the user zooms in or out: //Show or Hide layer based on a certain zoom level function onZoomend(){ if (map.getZoom() >= 11) { map.addLayer(mylayer); } else { ...


0

I am feeding my vector data into a OSM-like postgis database, and use Mapnik to render tiles from that (only the vector data, not together with other data). The mapnik style allows to create a transparent background: Map bgcolor="#ffffff" For displaying, I use openlayers, but leaflet should do as well: http://powerland.bplaced.net/osm-power.htm


0

It turns out I just needed to use an else if statement in the onEachFeature function, which uses layer.bindPopup. function onEachFeature(feature, layer) { if (feature.properties.Anum) { layer.bindPopup( '<center>' +feature.properties.Anum +'<br><center> Hunting District: ' +feature.properties.DISTRICT+ "<br><center> Elk ...


1

Computing a Convex Hull is possible in OpenLayers by using the external JSTS library. Although I haven't tried its implementation for convex hull, I have used it to create buffer/union etc. For more please go to this url also here you will find its implementation.


0

Check out my fiddle here, I think this is kind of what you're looking for --- http://jsfiddle.net/mkhines/SZk4u/embedded/result/


1

You would have to store polygon IDs in onEachFeature(feature, layer) handler (e.g. layer._polygonId = feature.id), so later you can iterate over layers (e.g. jsonLayer.eachLayer(function(layer) { setHighlighted(layer, doesRelate(layer._polygonId, selectedId)); });.


2

AFAIK the label of a feature has by default the same z-index than the marker and the "correct" way to change the z-index of a marker is with the constructor option zIndexOffset or the method setZIndexOffset.


2

Terraformer can parse WKT, and it can project from Geographic Latlong to WebMercator, but it can't write a WKT. However we can build the WKT string from projected polygon. First refer to the terraformer-core and teraformer wkt parser libraries in your code, like this: <script src="terraformer-1.0.3.min.js"></script> <script ...


0

As stated in the Esri Leaflet API Reference: Your map service must be published using the Web Mercator Auxiliary Sphere tiling scheme (WKID 102100/3857) and the default scale option used by Google Maps, Bing Maps and ArcGIS Online. Esri Leaflet will not support any other spatial reference for tile layers.



Top 50 recent answers are included