Is there a turfjs method that will let me increase the density of a linestring? If not, is there some other one-line to do that?
var line = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
-24.78515625,
2.7235830833483856
],
[
-6.328125,
0.3515602939922709
]
]
}
};
I'm not sure what exactly you mean by "increase the density", but I'll assume you mean you want to add more point coordinates to the linestring. I don't know of any built-in way of doing that, but it wouldn't be too hard to do it yourself if you just need to add more point coordinates into the linestring.
One way of doing this would be to get the midpoint of the first two points and add its coordinates to the linestrings coordinates. There is a turf function for this called turf.midpoint(). Here is a link to the documentation for that.
http://turfjs.org/examples/turf-midpoint/
You should be able to create two points using the existing coordinates for the linestring. You would then call turf midpoint on those two points to obtain a new point in the middle of them. You can then take the coordinates from the resulting point and add it to the linestring. Note that you will want to insert the coordinates in between the two existing coordinates, not just push it onto the end.
If that is not what you meant, or if you need a code example just say so and I will update this answer.
Related
I construct three polygons in the google map using the help polygons in google Map API for developers site. They are look like one polygon inside an another polygon .When my page is loaded all three polygon are loaded.How can i get the inner polygon when the outer polygon is zoomed or clicked in google map?Image:polygon inside another polygon
Your polygon are just place in postion that appear as one is inside another
for google maps the way you place your polygon had not a topological meaning
A easy eay for avoid that a larger polygon is over a small one could be based on z-index
assignin z-index with higher value to the polygon over the others eg:
// the larger - at base
var polylgon1 = new google.maps.Polygon({
...
zIndex: 100
});
// the middle - at medium leve
var polylgon2 = new google.maps.Polygon({
...
zIndex: 200
});
// the smaller - at top leve
var polylgon3= new google.maps.Polygon({
...
zIndex: 300
});
I could successfully load location data (lat,lon) at my Dashboard UI in tabular form using Odata API. Now I need to display them in a Map. I'm referring this as sample. Here is images of my dashboard table . Now from my table, I only need to display the location of the first row data in my map. please help on how do i do that?
According to One-Step GeoMap Example
it should be possible, to use any image for a spot.
In section “Resource Handling for Visual Objects” it says:
In addition to the semantically-typed Spot with a built-in visualization, you can use any image for a Spot.
The image needs to be loaded as a resource and can be referenced by Spots.
Since the Spot was built for images like pins, the image is, by default, aligned in a way that the bottom center of the image is at the given geo position.
For other images, a center alignment might be more appropriate.
Here is the code for JavaScript Views in UI5:
var oVBI = new sap.ui.vbm.GeoMap({
resources : [
new sap.ui.vbm.Resource({ "name" : "SAP_logo",
"src" : "images/SAP_logo.png"})
],
vos : [ new sap.ui.vbm.Spots({
items : [ new sap.ui.vbm.Spot({ position : "20;0;0",
tooltip : 'SAP',
image : "SAP_logo",
scale : "0.2;0.2;0.2",
alignment: "0"})
]
})]
});
I am drawing shapes from a JSON using Coregraphics and the co-ordinates span from -ve to +ve axis. I am able to draw it properly using translation, but as my co-ordinates are pretty large, the drawing goes out of bounds of the view. is there a way to shrink and fit the drawing to the view bounds? I tried some scaling but didn't work. ( I cant use an image context as it will become blurr when zoomed, I am trying to get some vector).
Please find below the sample project
DrawShapes from JSON
In the shapes.json I have points like below and the points 500,....570 are drawn out of bounds, I want to fit the entire drawing with in the view bounds after the drawing is completed.
"X": -200.07484,
"Y": 50.60354
},
{
"X": -500.07484,
"Y": 400.95078
},
{
"X": 570.77671,
"Y": 400.95078
},
{
"X": 570.77671,
"Y": 100.70688
Ok, After a lot of trials, I am finally able to fix the problem. I got a nice utility from MMScalableVectorView, where in which there was a method to adjust the content mode according to the entire drawing size and the actual view size.
More details: MMScalableVectorView Site
I am not posting the code here as it is his code. Look for the below method in the code
- (void)applyCTMTransformsForContext:(CGContextRef)context frame:(CGRect)frame
I have updated my code which now fits according to the graphic size.
How to add markers at particular points (x,y) in high-chart line graph?
I have tried this:-
marker: {
symbol: 'square'
}
Am adding x and y values as dynamic array.I need to iterate the array in a loop and plot markers manually at certain points .Is it possible?
probably the best way to do it is to add a data series that represents the marker, so it would be something like this (pseudo-code):
var myMarkerPosition = myValueFromArray;
mychart.addSeries(myMarkerPosition);
and you can then do something like:
mychart.series[1].update({ symbol: square });
later on if you want to. Don't forget to replace your marker if you want to move it to another position by updating it.
Is it possible to make the symbolizer of a feature be a polygon?
Openlayers 3 has a ol.style.Circle and ol.style.RegularShape symbolizers for example. Is there something equivalent to a hypothetical ol.style.Polygon? Whereby you could make a dynamic symbolizer from multiple points?
The reason I want to do this is because I have markers on my map that are dynamically shaped depending on the data for that marker. It is possible to simply draw a ol.geom.Polygon at each point, but then they are not zoom independent. I want to have markers that are zoom independent, meaning that their size on the screen does not change when I zoom in or out.
And just to be clear, using raster images (for example in ol.style.Icon) is not possible. There are way too many markers in way too many shapes and colours in my project.
Yes, this is possible. ol.style.Style takes a geometry argument that you can use to overwrite the geometry that is used to render a feature.
var style = function(feature, resolution) {
// construct the polygon taking the resolution into account
var polygon = new ol.geom.Polygon(...);
return [
new ol.style.Style({
geometry: polygon,
stroke: ...
fill: ...
}),
];
};
Also see this question: Drawing a Speed Leader line in OpenLayers