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

New answers tagged

0

A good tool is leaflet-control-geocoder (see demo with Google, Nominatim, Bing, and Mapbox services). I prefer to use Mapbox for geocoding, it works much better with US addresses compared to Nominatim, at least in Connecticut. You will need to create an account and get the public API key. With their new pricing rolled out in June 2019, you get 100,000 ...


3

You can't. Google does not let developers to control the amount of POIs being shown, and does not let developers download POI sets. Furthermore, each GMaps user will see more or less POIs depending on their own search history. (And this is your periodic reminder that using GMaps' tiles goes against Big G's terms of service; and that's why GoogleMutant ...


0

You can try the leaflet-geosearch plugin. The OSM demo seems to be what you are looking for. There are other options you can find on leaflet's plugins page. Please remember that the quality of the results depends on the underlying data, Google works very hard on their data. That's why it's no longer free to use. Also note that the OSM Nominatim API is ...


1

You can use layer event handler to process mouse click event, see sliced GeoJSON example http://leaflet.github.io/Leaflet.VectorGrid/demo-geojson.html (example does not work in IE11). Example below catches mouse click event for L.vectorGrid.slicer layer, changes feature line color from black to red and displays popup with feature id at click position. EDIT:...


0

I'm not sure I follow the logic you are trying to achieve by using zoomend event, but when you fit to bounds, the zoom doesn't necessarily change - it might be that only the bounds have changed. Try checking the results from moveend event mymap.on('moveend', function(event) { var bounds = event.target.getBounds(); }); You might also want to prevent ...


1

Thanks TomazicM for the effort. Issue is solved as you already know. I added the el.marker.bounce(x) to the already existing highLightItem function. Thanks again helped a lot. `const res = Array.from(document.querySelectorAll('.item')); console.log(res) function highLightItem () { for(const el of res){ el.onmouseover = function (){ ...


0

sas.planet is my favorite tool. You will use it forever. for more info : SAS.Team SAS SAS.Planet https://php-full-stack.blogspot.com/2019/06/sasteam-sas-sasplanetbin.html


0

There is nothing wrong with the marker positioning, it just depends on the way marker icon is defined. Since you defined marker icon without iconAnchor option, marker is positioned so that center of the icon is at [position.lat, position.lng] position. If your icon has dimensions [35, 46] and you want the bottom tip of the icon to be at desired position, ...


2

@Stefan's answer is essentially right, but more correct way of modifying TimeDimension plugin would be through extending/modifying it with include method, thus without need to edit source: L.TimeDimension.Layer.WMS.include({ _createLayerForTime: function(time){ wmsParams.time = new Date(time).getFullYear(); return new this._baseLayer....


1

You will have to modify this line in the source file from wmsParams.time = new Date(time).toISOString(); to wmsParams.time = new Date(time).getFullYear(); Here is a demonstration: JS Fiddle.


-1

the S in "extractTimestamp" needs to be lowercase


1

Since you need acces to feature marker to bounce it, the simplest way to achieve this is to add marker as feature property upon marker creation: pointToLayer: function (feature, latlng) { var myMarker = L.marker(latlng, {icon: redFlag}); feature.marker = myMarker; return myMarker; }, Now when building your item list you can access marker ...


0

Leaflet Routing Machine plugin has no built in method to toggle itinerary display. One very elementary solution would be to add transparent div element with absolute postion on the top of L.Routing.control container and attach onclick event function to it. This function then toggles itinerary display: <style> .legendClickArea { position: ...


1

These are two different sets of bounds: polygonLayer.getBounds(); call is giving you layer bounds for polygonLayer layer, regardless of the current view. event.target.getBounds(); call on zoomend event is giving you current map view bounds.


0

You can try this one: https://github.com/JohnnyMoonlight/Leaflet-convex-hull It calculates a convex hull and draws the according polygon. The function showConvexHull() uses an array of leaflet LatLngs, creates a convex hull polygon and adds it to mymap.


0

For those using react-leaflet, use: <Map attributionControl={false} />


0

I found the answer. It is how you construct your dynamically generated DOM element, wich in this case is the popup. Create one empty div with id="popup" in the div with id="mapid" in your HTML file. The rest is generated dynamically. The if statement of the eventlistener only needs that block of code necessary when a condition is true. const ...


0

This inability to handle the covered layers seems to be because of an known issue of leaflet: Related to: #5739, #5752 This is definitely an issue. Adding any kind of canvas layer blocks events to any other layers below it in the stack 😞 There is an event forwarding PR (#6012) that was previously considered but needs further work. There is ...


2

It might look dumb but that's how I did it after all. Hope someday someone will find it useful. Basically I just calculated routes using mapbox directions api (it's free and you can send up to 300 requests per/min) and used it's summary (btw it appears to me that the most comfortable way is to use LRM ONLY to draw nice looking routes and if you need some ...


0

The correct way of using Leaflet Ajax plugin is to process GeoJSON data after it has been loaded. You can use data:loaded event for that: points.on('data:loaded', function(){ points.addTo(map); // any other action on loaded data .... });


1

EDIT1: Solution below was first attempt. It is working, but is quite complicates. See simple solution at EDIT2. Upon investigation it turns out that quite a big part of routing process depends on adding L.Routing.control to map. To force route calculation and prevent showing of route on the map requires some hacking trickery: Itinerary display must be ...


Top 50 recent answers are included