Tag Info

New answers tagged

0

Further to that simply include the tokml.js file Then this will generate the kml. JSON.parse is required for tokml to work. the options for tokml documentname documentdescription simplestyle are optional var kshapes = JSON.stringify(drawnItems.toGeoJSON()); var kmlDoc = tokml(JSON.parse(kshapes), { documentName: 'My Polygons', ...


0

I quickly grabbed your and slapped up something. You seem to have redeclared the drawnitems further on - not sure why Function at the bottom of the javascript should get you what you need. genKml() var bounds; var plotbounds; var count=0; var checked =1; var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', osmAttrib ...


2

I am looking at the same issue. Firstly Converting to geoJSON and then KML. This tokml looks promising and seems to work. First problem is geoJSON does not recognise Circles, so i needed a workaround foir that - found on another thread. So what I am doing. In need a function to replace circle shapes with calculated polygons when added. Then a function to ...


1

Yes, you can! Actually I built something similar in this example some weeks ago (the basemap switcher doesn't look great, but the functionality is there): http://bl.ocks.org/iriberri/08abc420a376053c71d4 You can just save the basemap layer into a variable and change its _url parameter. Then, just redraw it: ...


2

Both will appear to change size as you zoom, depending on your reference: L.circleMarker will change size relative to the map, but not relative to the screen (radius in screen pixels stays the same). L.circle will change size relative to your screen, but not the map, as you zoom (radius in map units stays the same). For me, it works as expected in your ...


0

Several things seem to be wrong in your code. When you have forms inside a Leaflet popup, you want to avoid form submission in the classic way. You typically need to submit using some AJAX behind the scenes that prevent reloading your page. In order to do this, you need to prevent the default behavior for form submission. This question discusses how to ...


2

The official definition for EPSG:3857 is +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs As you see, it is calculated on a sphere (a=b). Your formula is a bit contradictory: You define a lat-long coordinate system on the WGS84 ellispoid, then you add +init=epsg:3857 which should ...


3

POLYGON((-90.89 46.67,-90.89 46.67,-90.89 46.67,-90.89 46.67,-90.89 46.67)) Looks like WKT. If it is, you can convert features/layers/geojson to WKT using Wellknown or Wicket-Leaflet


2

Indirectly, using tokml, after first converting to geojson: <html> <head> <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" /> </head> <body> <div id="map" style="width: 700px; height: 500px"></div> <script ...


0

If you're using two tile layers for google maps hybrid satellite view, here's an example: https://github.com/SnakeO/mapbox-with-google-maps-hybrid-tiles


0

I tried to check if my MapBox data is ok and I tested the code in Plunker: L.mapbox.accessToken = 'pk.eyJ1IjoiZm5ldmlzdGljIiwiYSI6IkZyYy03U28ifQ.tI5Od3maJWFflOMcit5vDg'; var map = L.mapbox.map('mapbox', 'fnevistic.n7o8oi8c', { 'center': [45.25, 18.55], 'zoom': 12 }); Everything is working fine. Map is displayed, pop-up is working. Now I'm trying ...


0

What are you actually doing? If you get your coordinates in to 4326 using Proj4, then you can add those points straight to the map, or form geojson points and add them. I'm suspicious you're overthinking it though! Check out the top example here: http://leafletjs.com/examples/geojson.html - it should be obvious from there how to go from lat/lon (WGS, ...


2

Building from the comment by @elrobis here is an example using jQuery for getting the georss and adding simple markers to a map: <html> <head> <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" /> </head> <body> <div id="map" style="width: 700px; height: 500px"></div> ...


0

there's no need to replace mapbox.js w/ leaflet. as @alexgleith said, it 'just works'. // mapbox.js v2.2.1 esri-leaflet v1.0.0 var map = L.mapbox.map('map', 'mapbox.streets') .setView([45.526, -122.667], 13); L.esri.featureLayer({ url: 'https://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis/rest/services/Heritage_Trees_Portland/FeatureServer/0' ...


0

You can accomplish this using the following: L.mapbox.tileLayer('https://{s}.tiles.mapbox.com/v4/YOUR_MAP_ID/{z}/{x}/{y}.png?access_token=YOUR_ACCESS_TOKEN') All you have to do is replace YOUR_MAP_ID and YOUR_ACCESS_TOKEN in the above snippet.


3

You can almost certainly replace the mapbox.js library with leaflet.js. And I'd be surprised if the esri-leaflet library doesn't just work with the MapBox version of leaflet. I've got an old trivial example here (click on the map, or turn on the layer visibility): https://maps.gcc.tas.gov.au/propertyinformation#16/-41.4656/147.1808 Code here: ...


0

It looks like you've gotten thrown off track by the example you were following, which uses an old version (7.0.9) of the noUIslider library. The new version that you've included in your code (8.0.2) has different syntax for many operations, as described here. You should be able to get it working by changing one line, from range = $("#slider").val(); to ...


0

Thanks everyone, finally i found out that i wouldn´t update the properties of my geojson. Everything is working now!


0

sorry after more searching I found it on this website pointToLayer: function(feature, latlng) { var smallIcon = L.icon({ iconSize: [27, 27], iconAnchor: [13, 27], popupAnchor: [1, -24], iconUrl: 'leaflet/icons/' + feature.properties.pcp + '.png' }); return ...


0

Yes, OSM provides boundaries if you pass the parameter polygon_geojson = 1, I use MapQuest webservice which is a mirror of OSM: var mapquest_search = 'http://open.mapquestapi.com/nominatim/v1/search.php'; var params_mapquest_search = { params : { polygon_geojson : 1, 'accept-language' : 'pt-BR', addressdetails : 0, format ...


0

I resolved this issue in a different manner (this is an approach for relatively sparse tiles). The first time I load the tiles, I send an AJAX call back to the server and walk through the tiles directories sending back the existent tiles in a list. This list format matches the way your api request the tiles. Then, before requesting a given tile, I look ...


0

Mapzen provides boundary data for all admin levels extracted from OpenStreetMap data as GeoJSON, divided by country as part of their Borders project. The data is available for download at https://mapzen.com/data/borders/


1

Baed on the Openstreetmap database, there is a service https://osm.wno-edv-service.de/boundaries/ which lets you select and download boundary data in various formats. Just expand the nodes on the left panel of the countries you want. If this is too slow for you, take the data from http://www.gadm.org/country or http://www.naturalearthdata.com/downloads/.


1

You can export data for several boundaries from the main OSM database. Administrative boundaries are complete in OSM for admin_level=2 that are for whole countries, and they are very up-to-date. The deper you go in admin_level there are countries that have 100% coverage for each place region, other countries still have some gaps. When using data from OSM, ...


1

I'm not sure exactly how your geojson is formed, but the style argument in L.geoJson allows you to set styles for each feature. From this example: L.geoJson(states, { style: function(feature) { switch (feature.properties.party) { case 'Republican': return {color: "#ff0000"}; case 'Democrat': return {color: ...


0

I have the same problem right now. So there are my steps: 1)create tiles in tileMill 2)create .png tiles in qgis using plagin MBTiles extract 3)create canvas mask on custom layer 4)right now I try to write piece of code that will extract hex color of images, and than convert hex color to dynamyc legend(cause there are about 150 types of color)


0

If the file size is too big, and you mentioned that it's going to increase more in the future, you need to use raster tiles. Actually, you should use CartoDB, upload your dataset there, you can make the dynamic chloropleth maps based on your data the server returned to you (as you mentioned this requirement in a comment). CartoDb gives a function ...


0

Well, I don't know how Golden Layout works, But I can Identify what is the reason behind the Issue. The problem is actually container re sizing, you can say that after the map starts rendering before the container finish to have its size. So, what you have to do You need to identify if you have a body onload event or document ready event like things ...


2

With Leaflet.EasyButton, things get dirt simple; name your icon and function (hover text if you want): var home = { lat: 70.3, lng: 50.5, zoom: 8 }; L.easyButton('fa-home',function(btn,map){ map.setView([home.lat, home.lng], home.zoom); },'Zoom To Home').addTo(map); (aside) and the zoom example answer by toms with easyButton: // make a bar ...


1

I don't think you will need to call the highlightSelection function, try to update the onEachFeature function to something like the one below to append content to popup window for each layer: // Action for each feature of the choropleth function onEachFeature(feature, layer) { console.log("onEachFeature"); layer.bindPopup('hello, popup'); // ...


1

The issue is you are trying to call the createLabelIcon function before it is defined. I updated the code on the jsfiddle you provided by putting the createLabelIcon function on top and the code is working now.


0

You could simplify the file. For this you could use QGIS. One option would be simplifying the lines, but that would probably break topology. Another option, depending on your file, is limiting the number of decimal places. That would reduce file size, but not complexity. Another option would be using TopoJSON. TopoJSON is perfect for administrative areas ...


3

GeoJSON is a JSON format, and in that, the order of the attributes is not important. It does not matter if you have the "type": "FeatureCollection" first, or after the "features" array. Both will work with all software that read GeoJSON. However please note, that I think you have another problem in your data. I think your latitude & longitude values ...


2

This is the compromise between client-side and server-side data handling. You can try using TopoJSON to make your file smaller, but it's a little tricky to run, and works better on polygons, including simplification. I think you're best off using a server platform. CartoDB is free for small use like this, and it's got other advantages like fancy ...


2

Qgis2web can minify the GeoJSON. That will gain you a bit. It can also reduce the geometry precision - the number of decimal places (as qgis2leaf can). Edit: qgis2web also supports scale-dependent visibility. Could this help?


1

Nowadays, you can use the getBounds method of a MultiPolygon object and than use that to set a map's bounds. var multipolygon = L.geoJson(foret); multipolygon.addTo(map); map.fitBounds(multipolygon.getBounds());


0

Check out this example. Based on your code snippet, you can do something like this: var ac_shpfile = new L.Shapefile("data/AC.zip", {onEachFeature: function (feature, layer) { /* Add some colors based on shapefile features */ }}); var baseMaps = { //"example title": example_layer }; var overlayMaps = { "AC Shapefile": ac_shpfile }; ...


0

It looks like the Leaflet Shapefile plugin has implemented L.Shapefile as an extension of L.GeoJson. L.GeoJson implements the ILayer interface, including the method removeLayer() Long way of saying that this should work: map.removeLayer(shapefile)


1

I figured this out; the parameters are needed which reference the URL. var NASAGIBS_ViirsEarthAtNight2012 = L.tileLayer('http://map1.vis.earthdata.nasa.gov/wmts-webmerc/VIIRS_CityLights_2012/default/{time}/{tilematrixset}{maxZoom}/{z}/{y}/{x}.{format}', { attribution: 'Imagery provided by services from the Global Imagery Browse Services (GIBS), operated ...


1

Yes, there are at least two ways. Leaflet's zoomend event. For example: map.on('zoomend', function() { var zoomLevel = map.getZoom(); if (zoomLevel > 10) map.removeLayer(highways); }); This is (very) incomplete. Most likely you will want to add and remove layers based on the current zoom level. Here is an example from MapBox for hiding ...


0

You can use the onEachFeature option of the GeoJSON layer to append the popups to each feature. And you can switch the popup contents inside of the onEachFeature function. I made an example on jsfiddle that you can use to see how it works. As you can see, the example displays a GeoJSON Layer with three markers on the map, two makers are cities with code of ...



Top 50 recent answers are included