leaflet use FeatureGroup() for edit. and I want to save data use toGeoJSON.but circle,marker... have point info only.
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[118.49561691284181,31.87595414652557]}},{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[118.5268591952,31.848500597]}}]}
I need save more info.how?
Strictly speaking saving this kind of data "to GeoJSON" is not possible because simply GeoJSON does not support circles.
GeoJSON supports the following geometry types:
Point, LineString, Polygon, MultiPoint, MultiLineString,
MultiPolygon, and GeometryCollection.
The old 2008 GeoJSON spec says nothing about circles http://geojson.org/geojson-spec.html
and neither the new one (august 2016) https://www.rfc-editor.org/rfc/rfc7946
If you want to save a point and its radius to represent a circle you need to make a format of your own, but this of course will not work out-of-the-box with leaflet's geojson layergroup.
Edit: seems some people went down that road already so you may wanna check this out:
https://github.com/Leaflet/Leaflet.draw/issues/390
They saving the radius in the properties of GeoJSON and extended the GeoJSON layergroup to work with that. A bit hacky, geojson spec goes down the drain, but it seems to accomplish what you want.
Another possibility is to convert your circles to polygons with an acceptable amount of nodes, then saving that polygon in GeoJSON.
Related
I have longitude and latitude coordinates which represent different types of geometry shapes (point, multi-point, polygon, multi-polygon and line string etc) that are stored in MongoDB. I'd like plot them (say each shape as a layer) using JavaScript. Map is not needed as a background although these coordinates represent building etc in the real world. I understand there are calculations as such are involved to convert coordinates to x and y on graph/canvas but not sure where to begin tbh. I'm very new to GIS and JavaScript so go easy on me please. I know this question sounds a bit vague but bottom line is I have coordinates that represent real world elements and want to plot them without a map background. I'd appreciate advises and suggestions. Many thanks.
The easiest way to do it is to use a Javascript mapping library such as OpenLayers or Leaflet. You could also do it with D3, although should you want to make your map more full-featured later, it will be much easier with a library that was designed for that type of thing.
If you are storing your data in Mongo as GeoJSON (GeoJSON website), you can add it to OpenLayers as a GeoJSON layer.
Disclaimer- My opinions might be slightly biased because I used to work for Boundless
I have a geojson file I would like to simplify. It currently contains about 33,000 records. The file is of all the roads in the state of Nevada and I would like to be able to remove the roads in cities(i.e. Las Vegas) because it is taking up a chunk of data, when those roads are easy to see from a leaflet map so they don't need to be drawn.
I have tried to use geojson.io and other geojson generators to try and remove the roads but it will take way too much time to manually delete all these roads individually. I was hoping there would be a something similar that I could draw a rectangle over the area I want to delete and it would remove all of those features.
EDIT
I have tried to simplify the layer with http://mapshaper.org/ but the file is still to large. If I try to simplify it more, the resulting roads would not be very accurate.
There are many ways that you can do this, but since you have already used mapshaper to simplify, we can use mapshaper to clip or erase features.
Using geojson.io I created a quick bounding box geojson called clip.json - with this I can remove features outside or inside of this feature from the roads geojson file. While I created a geojson to use to clip/erase features, you could use a pre-existing file the same way.
Drag both geojson files into mapshaper.org. Toggle the view of the road geojson (as only one layer is shown at at time, the current layer is displayed on the top ribbon and can be changed by clicking on the name.)
Once viewing the roads geojson, open the page's console window (top right of the page) and type:
erase clip.json
This will give you something like (using Nevada and a basic bbox for Las Vegas):
Now you can easily export the file and use it as needed.
To achieve the opposite effect, you would use clip: clip clip.json
I need a 'polygon' selector type functionality. Basically, the ability to drag lines to form multiple polygons; pref with the ability to edit the 'points' of the polygon after the shape has been 'closed' (but that's secondary) and/or move the polygons...
I generally dislike 'reinventing the wheel' and I figured I'd find tons of examples to work with, but I was wrong...
The polygon tool in Google Maps is just about perfect, but has anyone utilized it outside of GMaps? (I recall it required a GMap as an attribute from my work with Google Maps). Before I roll up my sleeves, I just want to ensure there isn't something already made (this is a very small part) - so if (a) Google Maps Polygon object is usable without a map, or (b) there's another library/project I'm missing please let me know.
Fabricjs is an option you can check.
Have a look at D3.js which has a great api for visualizing data and geo information. Besides the standard one-/two-dimensional brush there are plugins for more advanced types of brushes:
Polybrush. Providing a polygon brush.
lasso. Lassoing a selection by freely drawing a line path.
I am trying to migrate a map (used Polymaps so far) to Highmaps. If I use the world map provided from the Highmaps collection (which is EPSG: 102014, unusual coordinates), everything looks fine. If I use a GeoJSON file that comes in the WSG84 (EPSG: 4326) format, then all the shapes look horizontally stretched.
The solution that I used for some maps was to simply grab a GeoJSON file in the format that Highmaps likes, but for this particular case it's not possible.
Expected result
What I actually get
What I tried so far is converting the original GeoJSON from EPSG 4326 to EPSG 102014, but it still looked bad. Is there any way I can make that original GeoJSON look good on Highmaps?
I had the same problem with the EPGS4326 (WGS84) so I reprojected my geojson to EPGS3857 (web mercator) and in highmaps looks right.
In their web they have an example that use the proj4js library to reproject on the fly, but I not been able to make it work to transform from 4326 to 3857, so I reproject the original geojson.
The transform is supposed to work including this on the geojson:
"hc-transform": {
"default": {
"crs": "Your map projection in proj4 string format, as supported by pro4js"
}
}
I wanted to ask you about the way to make spatial interpolation in google maps API. This means- I have values for some points inside an area and want to recalculate values for every point in this area (and create an raster overlay).
In "offline" GIS softwares, there are more methods to do this. For example Kriging (http://en.wikipedia.org/wiki/Kriging).
Thanks for answer
There is no real practical way to do such a thing. Spatial Interpolation is something you really need a full-blown GIS to accomplish. It requires storing, analyzing, and presenting data in way that ArcGis or QGis is best suited for. There is some new feature in ArcGis Online that works with Google Maps API but I don't know much about it and am unsure if it would be any help for you but a link is here.
I know, its not something geostatiscically correct, but I have made this:
- I have created a net of rectangle polygons.
- I have connected all my points to polygon they lie and have made mean value for polygons with at least one point
- I have checked every polygon without points and at least 2 neighbourly polygons with points, and have made mean from this neighbourly values
- I have checked again all my polygons with values and at least 2 neighbourly polygons with values and smoothed origin values according to the neighbours´ values.