Hot answers tagged

9

FYI... I believe this has changed for OL3 V3.5.0, so gcarrillo's answer would be: new ol.layer.Vector({ title: 'added Layer', source: new ol.source.Vector({ url: 'mygeojson.json', format: new ol.format.GeoJSON() }) }) You can see the changes here: ...


6

This is because boundedBy / bbox is a property that OpenLayers creates when parsing the GML, it is not a real feature property. So when you update, you should clone the feature and get rid of it. Some example code: // do a WFS transaction to update the geometry var properties = feature.getProperties(); // get rid of bbox which is not a real property delete ...


6

Leaflet author here. The vectors should redraw properly. The quote by @nathansnider is referring to the fact that vectors are not reprojected, but they animate with a CSS transform during animation. If they don't redraw, you should set up a JSFiddle test case and file an issue on GitHub. update: they currently redraw, but are not reprojected until the ...


6

The order is important. You can't add something to the map before it is defined. Try in this sequence. First define the termini, metroStops var termini = ... ; var metroStops = ...; Then define the basemap, but don't add it to the map yet var osmBase = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png'); var baseMaps = { "OSMBaseLayer": osmBase ...


5

This is a general answer since you didn't provide any code to work with. Note that I assume you have managed to work out the QGIS2LEAF plugin. The output of the plugin gives you a folder with an index.html file, which contain the webpage main code, and few more folders described below. CSS: contains CSS styling files, including own_style.css that is meant ...


5

If I understand what you are asking, you have a basemap of the US, and geojson layers for zip codes and county shapes, and you want to toggle (turn on or off) the geojson layers? Leaflet layer control is designed for this Documentation http://leafletjs.com/reference.html#control-layers Example http://leafletjs.com/examples/layers-control.html Leaflet ...


5

There are two mode in MapServer in fact and it can be confusing for end users without knowledge about the project history. The first one, the now mostly outdated mode cgi (the url contains mode=browse) way where you don't rely on standards OGC webservices. It was supported in OpenLayers 2 by default because of history (more Mapserver instances not using ...


5

GeoTools is a Java library which can read and write GeoJSON and provides access to features like area via the JTS library. It will also help you to reproject the geometries from the lat/lon of GeoJSON to a suitable projection for calculating areas in m^2.


5

[Final Answer] I bet you can easily resolve this by setting the map's maxBounds equal to its initial bounds immediately upon loading. :) Just add this to your initializing code once your map variable is ready. map.setMaxBounds(map.getBounds()); [Original Response] When you instantiate your Leaflet map, you just need to pass in a maxBounds option ...


5

As already pointed out in the comments, the problem is that you are directly opening the HTML file in your browser. This will show up like file:///C:/map.html in your address bar. The OSMGeocoder plugin is calling the URL location.protocol+//nominatim.openstreetmap.org/search (see source code). This works on webservers because the location.protocol is ...


4

If you need a modifyend event why dont you use it within the modify interaction.(I guess you use a modify interaction) check this modify.on('modifyend',function(e){ console.log("feature id is",e.features.getArray()[0].getId()); }); This event is available in the latest versions of ol3. In my code snip, I assume you only modify one fetaure at once ...


4

You can use: map.getViewport().addEventListener('contextmenu', function (e) { e.preventDefault(); console.info('contextmenu'); var feature = map.forEachFeatureAtPixel(map.getEventPixel(e), function (feature, layer) { return feature; }); if (feature) { // ... } }); Tested: Firefox && Chrome ...


4

Dashed lines can be done with: new ol.style.Style({ stroke: new ol.style.Stroke({ width: 3, color: 'rgba(255, 255, 255, 1)', lineDash: [.1, 5] //or other combinations }), zIndex: 2 }) I've made you an online example! http://plnkr.co/edit/AW1YNC?p=preview You can use this online "tester" to get various combinations: ...


4

I think you need to use IdentityManager from the API that allows you to sign in with your arcgis.com account and then receive access to the data. Whatever users from your organization that have accounts can sign in as well. https://developers.arcgis.com/javascript/jsapi/identitymanager-amd.html And here is a sample that shows what I think you are trying to ...


4

I don't have Maptiler 1.0 Beta 2 to test with, so I'm making a couple of assumptions: You have tiles in the XYZ format and not the TMS format. I'm making this assumption because your screenshot shows "Google Maps Compatible" selected You are using Openlayer 2.x What I would do is to put the the two folders in one main folder such as: Map MAP_1A_1_1 ...


4

I think that graduated sizes are quite a recent QGIS feature (?2.10). I've therefore not implemented them yet in qgis2web. I can have a look at it, though. In answer to your other question, no, I'm not aware that you can directly use an SLD in OpenLayers3. Others might know better. UPDATE I've committed a change to the master branch at ...


4

map.flyTo() should be already available in Leaflet 1.0? However the parameters are different. See https://github.com/Leaflet/Leaflet/blob/master/src/map/anim/Map.FlyTo.js


4

You can do this several ways, I think that the easiest (if you only have a few GIS things to do) is to use Turf see here There are also a couple of GIS library whom are a bit heavier (size wise) leaflet: how to After you can also try openlayers3


4

No, this isn't possible. For one, if you were to load both API's, you would end up with a namespace collision with Dojo's Define and Require. For two, the API is obfuscated (not human readable) making it difficult to extract just the parts you need. Even if you could, there may be dependencies in that module preventing you from using it with an older API.


3

I am having the same issue in Google Chrome. Everything works correctly in Mozilla or IE. Here is my CSS definition of the div where the map is loading. .map { height: 35em; width: 100%; border-radius: 5px; border: 0.2em solid #209CA6; } When I go full screen this happens: I realized that reason why this is happening is the fixed setting of the height ...


3

In ol3 version 3.10.0 things have changed. So is more clear than older versions but still more complicated than ol2. So for TILE (ol.layer.Tile) layers your code snip should look like: //declare the layer var osmLayer = new ol.layer.Tile({ source: new ol.source.OSM() }); //asign the listeners on the source of tile layer ...


3

As others have correctly pointed out, the GeoJSON and WKT formats do not support circular geometries in any way. Circles are not in the KML specification either. This makes it a pain when trying to write out a map frame to KML, GeoJSON or WKT. OpenLayers v3 does have a way to approximate a circle with a polygon, but it isn't pretty as it involves ...


3

Kaarel´s answer should be marked as the correct answer. You need to call the loadFeatures function from the AJAX call. I created three jsfiddle to demonstrate ol 3.5.0 calls via AJAX for ol.format.GeoJSON (JSON and JSONP) as well as ol.format.WFS. WFS http://jsfiddle.net/goldrydigital/9d3jzpna/ JSON http://jsfiddle.net/goldrydigital/ucspgvx0/ JSONP ...


3

You can by using ol.source getClosestFeatureToCoordindinate() and feature get(). Assuming your OpenStreetMap data is loaded into ol.source.Vector called osm. map.on('click', function(event) { var osm_id = osm.getClosestFeatureToCoordinate(event.coordinate).get('osm_id'); window.alert(osm_id); )}


3

It seems you re mixing some concepts features[i] = new ol.format.GeoJSON( url: './testData.geojson') }; The above code can't work because the ol.format.GeoJSON API does not accept url as a parameter eg the official doc. You also try to loop on a GeoJSON call (if I consider above sample was intented for this) The normal way (there are more than one) ...


3

You could – along the lines of map.on('zoomend' … insert a conditional statement into layer.on('click' … querying map.getZoom(): layer.on('click', function() { if(map.getZoom() < 10) { map.fitBounds(layer.getBounds()) } });


3

Outside of polling for size changes, there isn't a way to detect a resize of a <div>. I usually use absolute positioning on the map container and let Leaflet handle resize automatically. Like this: http://jsfiddle.net/asnyder14/0gsfdxeg/


3

The 4.0 beta 1 does not support KML. The KMLLayer will be supported in a future beta version. Beta 1 only supports the modules documented in the API Reference.


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


3

See code example Leaflet users map https://github.com/bmcbride/leaflet-users-map by Bryan McBride. There is used SQLite DB, but her easy replace on MySQL.



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