This is my first posted question despite using StackExchange for a few years now. I've been stuck for quite some time trying to figure out this issue with OpenLayers. The problem is as follows:
I have a bunch of features plotted on a map and am able to select features in various ways (e.g. drawing a box around them, clicking on individual features, entering a zip code that selects all features within that zip code, etc.). This all works fine. The issue is that I have a clustering strategy on the features layer and when I zoom out, currently selected features get clustered together with unselected features and those unselected features will become selected when I zoom back in. What I'm trying to accomplish is to NOT have the previously unselected features become selected after clustering.
This behaviour (keeping selection of subfeatures after zooming in with selected cluster) is buried quite deep inside of Strategy.Cluster code. One solution would be to get deep into the code of Strategy.Cluster and making it remember really selected features and select only those on zoom in (actually - on reclustering, or calling Strategy.Cluster.cluster()). Second would be to track the selected features outside of openlayers by subscribing to event featureselected and reselecting features on zoomend.
Related
We currently use the model derivatives API to upload 3D models and later visualize them in a browser with the Autodesk Viewer v7 (previously Forge Viewer).
For different reasons we have been trying to hide and show parts of the model, but to do so in some cases we need to be able to hide geometric pieces of some elements while still being able to see the rest. For example if we had an element in gray (see image below) we would like to make the part of the element in red transparent.
I have looked into the Viewer API docs and there are functions that allow showing and hiding complete elements, but not cutting elements along a custom path.
While the docs mention the overlay functionality which enables us to add custom geometries by interacting with the THREE library that the Viewer runs on, drawing a copy of the whole model seems inefficient and prone to giving bad results.
Searching in SO I found that the THREE v71 library (which is the version the Viewer uses) has the possibility of occluding elements with the colorWrite option. See these links for reference:
three.js transparent object occlusion
Occlusion of real-world objects using three.js
I tried implementing something similar by using the colorWrite key when creating a new Three Material in an overlay, but nothing happens. This makes me think that either the Autodesk Viewer overwrites the render order (which makes sense) or openly ignores the colorWrite option. Does anyone know why and if there is a workaround for this? Or does anyone know if there is another way to cut an element that I'm not considering?
Please note that we have to do this with multiple elements at the same time and that reuploading the model periodically is not an option for us.
I got the following feedback:
The approach linked in the SO thread doesn't work, because we ignore both the colorWrite material property and the renderOrder mesh property. I also think that the approach would not work as expected in general, because using an invisible object to occlude a part of another object would always be view-dependent, and also occlude other objects in the background (so it wouldn't just 'cut out' a part of a single object).
Generally, this is not really a use-case for LMV, because it's a viewing tool, not a solid modelling tool.
Cut planes might help to get some of what you want, but they also have limitations:
It's possible to define multiple section planes to construct a 'shape' (that's also what the section box does internally). But since they are infinite, you wouldn't be able to cut away parts of one object, but not other objects (or other parts of the same object that intersect the cutplane). They're also designed to be 'outward' facing. The section box, for example, can only be used to narrow the scene down to some elements of interest. It's not possible to do the opposite, i.e. cut out some inner part of the design and keep everything around it.
This is what the section box could offer:
If I select some items of the model using-
viewer.select(dbids, viewer.model, Autodesk.Viewing.SelectionType.OVERLAYED)
and then try to zoom in/out or rotate the model, the viewer gets slower. But if I select some items using mouse click it doesn't affect the viewer at all.
If I select items using-
viewer.select(dbids, viewer.model, Autodesk.Viewing.SelectionType.REGULAR)
the viewer first hides everything except the selected items and a moment later shows up. It also hide some parts of the selected item(s). The navigation is smooth now.
This is before selection-
This is after selection-
Is there any way to overcome this slowness and the hidden parts issue.
Let me first explain the difference between the overlaid and regular selection highlighting:
Overlaid highlighting means that the selected objects are rendered twice. Once with their standard material, and once with the overlay material (so that they can be seen through obstacles as well). Of course, this doubled rendering may have significant impact on performance, especially if you select many objects (for example, by selecting a group of a large number of objects in the model browser).
Regular highlighting was introduced to mitigate the performance problems. In this case, instead of rendering the selected objects twice, they're simply rendered once, with a specific color tint applied to their regular materials. The drawback of this approach is that the selected objects are not visible through obstacles.
Now, to your problem: "regular" selection highlight is definitely the right way to go if the "overlay" highlighting is slow, but the fact that parts of your model disappear is strange. I'm thinking there might be a problem with the model itself. Perhaps it's too granular or tessellated (has too many parts or triangles), so applying the "selection tint" to all the selected parts takes unusually long time. Could you please try both the "overlay" and the "regular" selection with another type of 3D model? If it works well, you may need to look at the settings of the application that's creating this problematic model, and see if you can decrease the tessellation levels.
I am brand new to Forge and making my way through some documentation but it seems quite hard to get some of the older examples working (pages don't load correctly etc) and I am currently using version 6, which seems newer than many examples too.
Is it possible in client-side code to take in some user data and generate a heatmap (overlayed ontop of the floor of a house) based on that data (i.e. different blocks of colour, it can be quite rudimentary).
This is using a Revvitt model uploaded to Forge and shown in the Viewer.
I have no experience with Three.JS but if anyone could point me in the right direction, show me a working example, or at least tell me if its possible I would greatly appreciate it!
There are a couple of options, with different levels of complexity:
You could use the official viewer APIs such as setThemingColor and clearThemingColors to add a semi-transparent color tint to selected objects.
If you need to overlay scene elements with anything more sophisticated, you could replace their original material with a custom THREE.ShaderMaterial. Just be sure to follow the documentation of three.js version 71 which is used by Forge Viewer. The process of adding new materials to Forge Viewer, and assigning them to specific objects is explained in https://forge.autodesk.com/blog/forge-viewer-custom-shaders-part-1. The article is a bit old, but I think the relevant parts of it (mainly the createShaderMaterial and selectionHandler functions) can be reused.
I have a Google map with a couple of Fusion Table layers (one with markers, the other one with polygons). I am styling them on the Fusion Table UI side, and then choosing the particular style with styleId on the client side.
The problem I am having is that on occasion, the markers appear as red dots instead of with the particular marker I've chosen in the styles (using icon from column). If I try again an hour later (without changing anything), the map now renders correctly.
My theory is that it likely has to do with how/when Google caches the tiles, since I noticed it this morning (Monday) on my map, after not visiting it since Friday.
1) Does this sound like a possible cause?
2) Is there any way to fix this? Some way to "Warm-up" the cache?
For the sake of completeness, I do truncate and repopulate the Fusion Table through the API once a day. This could possibly be wiping out any previously cached tiles, if my theory is correct.
Unfortunately this is a bug that we're trying to track down. In general the thing heals itself after a delay, as you've seen, but it can revert and flip back and forth. There's no workaround that we know of right now, but we are actively searching for the root cause.
I've seen this specifically when using multiple fusiontables layers. Reverting back to 1 layer seems to bring things back to consistency. For our production product, we've had to limit the intended functionality of the app due to this constraint.
I have tried multiple "tricks" to refresh cache, reload layers, etc. With more than one layer, we never were able to make it consistent.
Glad to hear that it's being actively looked at.
I have a custom Google map set up with custom markers for certain points with popup infowindows. I currently have it setup to show all locality labels (eg city/area labels) however the client has asked if we can hide certain localities and not others (so that the relevant areas of interest are always visible but the irrelevant ones are not). You can obviously set it to hide all localities (or other items on the map) but I cannot see anyway of only displaying certain ones? Does anyone know anyway of displaying certain ones and not others?
If this is not possible then presumably the only alternative would be to hide all locality labels and setup 2 different styles of markers, one that is a normal marker withpopup and one that is actually just a text label with no associated popup which can then be used to list the relevant locality labels? Presumably this is possible but is there a better way of doing it as this doesn't seem right?
Thanks so much,
Dave
I'm assuming from your description that you have created a MapTypeStyleapi-doc. And no, there is no easy way, using a Styled Mapdev-guide, to apply a style to specific geographic areas; it just provides the hierarchical model of styling rules.
To answer your specific question about how to create markers that function essentially as labels, the MarkerWithLabel utility library will provide you with a tool that does what you describe. That said, I wouldn't recommend trying to recreate a set of map labels for an area or region using markers; the misgivings you express in your question about this approach are valid.
If you need to implement something along these lines, I suggest taking a look at the following two options and considering if either of these are a good fit for what you are trying to achieve:
Custom Overlays
KML Layers