Hot answers tagged

2

what this error tells you is that you've lost the reference to the L.geoJSON layer you have named geoJson. It is not in scope in the geoJsonBounds function. You need to either pass the geoJson layer to the function or define it in a scope this function has access to. Can you post the full code?


2

Check the proj definition stored in the spatial_ref_sys, it should be different from the one used in the proj4js definition. For example, mine is the following: +proj=utm +zone=30 +ellps=intl +towgs84=-87,-98,-121,0,0,0,0 +units=m +no_defs Also epsg.io gives the one with the towgs84 parameters, so I'd change the Proj4js def.


2

You can use setStyle within the mousemove function: layer.on({ 'mousemove': function (e) { //I want to make the point a red style ? this.setStyle({fillColor:"#ff0000"}); ... } )}


2

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


1

[Edit: See Followup Below] When you instantiate your Leaflet map, you just need to pass in a maxBounds option among your map options. When this option is set, the map restricts the view to the given geographical bounds, bouncing the user back when he tries to pan outside the view. To set the restriction dynamically, use setMaxBounds method. ...


1

Your bounding box is 100% correct. But, presumably, your map is in EPSG:3857, so you can't use WGS coordinates directly. Transform it to 3857: var ext = ol.extent.boundingExtent([destLoc,currentLoc]); ext = ol.proj.transformExtent(ext, ol.proj.get('EPSG:4326'), ol.proj.get('EPSG:3857')); map.getView().fit(ext,map.getSize());


1

What is the size of your geojson? I think you need to register 'layeradd' map event, this event will be called only after the geojson [or any other layer] is properly added to the map. In this event, you can get the layer object and its extent, and then call map.fitBounds(bounds) to zoom to the layer. Here is the basic code: map.on('layeradd', function (e) ...


1

If the endpoints of your segments are within 5000 km of each other, then pick some suitable midpoint (e.g., the point halfway between the 2 midpoints), and use this as the center of projection for GeographicLib's gnomonic projection. Map the two line segments into this projection and solve the resulting 2d intersection problem. This will give you a good ...



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