I Want to display a raster layer on to my page using ArcGIS javascript API.
Loading Feature layer is easy and pretty forward but the raster layer is giving me hard time.
Here is the the MapService: http://ags.servirlabs.net/ArcGIS/rest/services/ReferenceNode/TRMM_30DAY/MapServer/0
which is Raster layer.
Do you have any ideas on how to do this?
How you add a map service layer depends on whether or not the service is cached. Look at http://ags.servirlabs.net/ArcGIS/rest/services/ReferenceNode/TRMM_30DAY/MapServer in a browser and see the following:
Single Fused Map Cache: false
Because it's not cached, you must use ArcGISDynamicMapServiceLayer, not ArcGISTiledMapServiceLayer. If it were cached, you could use either one.
map.addLayer(new esri.layers.ArcGISDynamicMapServiceLayer(
"http://ags.servirlabs.net/ArcGIS/rest/services/ReferenceNode/TRMM_30DAY/MapServer"));
Note that if you had a service with multiple layers in it and you wanted to display only a subset of them, you would create an ArcGISDynamicMapServiceLayer and then use its setVisibleLayers method to set which layers should be visible. In this case, you don't need to worry about it, because your map has only one layer in it.
You can add raster layers to your map using the ArcGISTiledMapService layer, for example:
// assuming 'map' is a reference to your map
map.addLayer(new esri.layers.ArcGISTiledMapServiceLayer("http://ags.servirlabs.net/ArcGIS/rest/services/ReferenceNode/TRMM_30DAY/MapServer"));
There are some good examples on the ArcGIS JavaScript API site here:
https://developers.arcgis.com/en/javascript/jssamples/#tiled_layers
One thing to be aware of with tiled layers is that you can only add tiled layers to your map if they are using the same spatial reference. You can't add a layer as a tiled layer with a different spatial reference as it's cache of tiles have already been produced using it's spatial reference. You can add a layer as a Dynamic layer to re-project it.
Related
I'm new to threeBox and I'm developing a mapbox-gl-js map that has a 3D buildings (fill-extrusion) layer from tiles source. I want to add a symbol/icon layer with elevation from tile source useing threeBox (like icon over special buildings etc.).
From what I have seen so far threeBox layers in Mapbox can be added only GeoJson sources, is it possible to add to threeBox layer a tiles source as one adds to MapBox layers?
Thanks.
I guess ThreeBox doesn't support vector tiles.
You may be able to hack something to work by using map.querySourceFeatures() to access all the buildings in the loaded viewport as GeoJSON, then using that. There are lots of caveats that you will discover. :)
I am using React Mapbox GL in my project and as i use Marker for about 10000 data points and performance is not that good. I have read the documentation and it says
Note: When rendering many objects, avoid using Markers as it will negatively affect performance. Use Layers and Features instead.
How to use Layers and Feature to display markers?
To render something with layers and features, put one or more Feature components inside of a Layer component. You can give each Feature a position using the coordinates prop.
Now, what's left over is to style these features. How you do this depends on what your markers previously contained, but for example, if you'd like to draw circles for each of the positions, you can set the Layer's type to circle and under the paint prop, provide values for circle-color and circle-radius (these are described in the mapbox-gl API docs.
For drawing images for each coordinate, you can use the icon-image layout property on the Layer (you would have to either use a preexisting icon or upload one to Mapbox Studio).
You can see some sample code in the demos, for example the all-shapes demo styles data with circles.
I'm working currently in a project where we need to create a new feature that allow to the user zoom in a Google Earth map embedded in a web app, and create a grid layout over the map, so the user should be able to "mark" some elements of the maps, for example, some specific buildings etc. But we need to create kind of square around the element, so it is not a single point, but at least 3 or 4 as needed to round the element.
We need to save those elements map with its coordinates and assign an ID to every element of the created grid.
Is it that possible? Is there a JS library that I could use?
Google Earth does not currently make an API or embedding available. If you don't need the full 3D view, then you can do this with the Google Maps API. There is a "drawing" library available that you can use to draw objects on the map. More info here:
https://developers.google.com/maps/documentation/javascript/drawinglayer
My question is about updating the data in leaflet.
Let's assume that we have geojson which we are changing into vector tiles using geojson-vt.js and displaying it on the leaflet map.
Similiary as there: geojson-vt example
Then i'm receiving an event / notifiaction that some linestring was changed, for example thise linestrings have a attribute color, which is using when displaying data, and this value has changed.
Then i want to update my map, but i dont want to recalculate, and redraw all tiles, but only this tiles where was change. How to do that?
It cannot be done. geojson-vt only allows for creating new geojson-vt instances, not updating them. Updating data in the internal structures is too complicated, and doesn't give any big advantages. This also means it's not possible to get a list of changed tiles, or even a list of tiles containing the updated geometry.
If this is really critical for your application, consider studying the code for geojson-vt for yourself, and proposing a solution.
If you have a set of static features and a set of possibly-changing features, consider making separate holders for them.
I have different layer's arrays, but I want to put one of these in foreground when I change it latitude and longitude.
How I can do that in javascript?
Thanks!
Browse over to the trusty Leaflet documentation, and look at the setZIndex() function on all tile layers.
layer1.setZIndex(1);
layer2.setZIndex(2);
It depends on whether your layer is Raster or Vector.
For layers inheriting from Path, such as Polylines, Polygons, etc use bringToFront
layer.bringToFront()
For TileLayers (and layer types that inherit from TileLayers) use setZIndex
layer.setZIndex(<number>)