How to hide certain locality labels on a custom Google Map? - google-maps

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

Related

How to show/hide part of an element in Autodesk Viewer v7

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:

Create custom maps where specific streets get specific colour [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm looking for a (good) solution to solve the following problem:
provide users with a searchable map
search is constrained to street names
a statically known set of street names needs to be coloured in a specific way (e.g. some get a strong red, a soft red, a strong green, etc)
So the user's experience would be to search for e.g. his own street, and see which colour his and neighbouring streets have. A bit like your typical map hotspots functionality, but really focused on the street level.
A sketch of this idea:
Does anyone know any approach to get to this? Combine a dynamically searchable map with a pre-colouring of let's say 10k streets?
I've looked at bing maps, google maps, here maps, osm, but none of them really seem to offer what I'm looking for. I don't want to query specific coordinates of a specific street given the query of the user, and then draw polylines along those coordinates - I want a "pre-baked" map, that works just like a searchable normal map, but happens to colour streets in a specific pre-defined way.
I'm happy with any good approach, doesn't matter how complex (offline rendering, dynamic colouring, ...). I looked around for possible solutions, but anything I found was focused on either providing a static image, or colouring just one specific street using e.g. a directions API.
Thanks for any input!
A couple of approaches to do this. Most of the map platforms you mention provide their road maps as static image tiles which doesn't give you the data you to do what you want here.
If you must use one of those platforms you will need to find an alternative source for the road data, host it and pull it into your app and style it like any other shape. One catch though is it is very likely that the data you find won't line up 100% with the roads that are in the map images for various reasons such as generalization of data, vintage of data, and width/centering method used for the road line. You can hide many of these imperfections by giving your line more width.
If you aren't locked into one of the map platforms you mentioned, you might want to consider a platform that uses Vector tiles for the base maps instead. Azure Maps (the product I work on) as well as Mapbox, both provide this. Vector tiles are a newer data format which contains all the same data as a map tile, but is basically a mini geojson file that has been compressed (zipped). This allows the raw map data to be accessible in the client. Using data driven styles you can then use metrics that each piece of data has to specify how to style each entity in a tile. However, when you are zoomed out vector tiles optimize themselves and combine shapes and sort them into layers. For each, all highways of a certain type will likely be a single shape in a tile, and the only information you will have to style on is the source layer name. When zoomed in closer and the name appears on the road, that name information will also be available in the vector tile. So depending on how you want to style roads, based on class/layer or by name, the zoom level at which this will work will vary. I have test app here that provides insights into the map tiles:
https://azuremapscodesamples.azurewebsites.net/Experimental/Inspect%20Features%20under%20the%20Mouse.html
I have a bunch of samples on data driven styling here: https://azuremapscodesamples.azurewebsites.net/index.html however they all use GeoJSON data via a DataSource object. All the same styling also works with a VectorTileSource as well, its just a different source of data. One caveat is you need to know what properties exist inside the vector tiles so you can style it.

Style Country - Google Maps API

I made a google styled map and now I want to add more features to it. The feature I'm trying to add is a way to style specific countries. I want to let my program select a country and then have that country appear differently on the map and stand out.
This is challenging because there are polygon ways to do this, but that would mean it is hardcoded and the country can't change. I want to be able to use this feature on different countries.
Thanks
I don't know of a way to do this with styles; I think you'd need to generate map tiles with countries coloured and overlay those map tiles on top of what you have already.

OpenLayers Clustering Adds Features to Selected Features Array on Zoom

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.

Can I style a Google Map?

How much control do I have regarding the styling of a google map?
Can I make it more closely resemble a site's colour scheme or are we stuck with pastels?
Controls
There is a decent description of the process to override the set of builtin Controls. So you have total control over the UI elements overlaying the map.
Map Tiles
I don't agree with the previous answers that you are out of luck if you want to change the images in the map itself.
The range of map types available give you a few options outside the pastel default map:
G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP, G_PHYSICAL_MAP, G_MAPMAKER_NORMAL_MAP,
G_MAPMAKER_HYBRID_MAP, G_SATELLITE_3D_MAP, G_DEFAULT_MAP_TYPES, G_MAPMAKER_MAP_TYPES
Obviously, this only works if you are willing to create the tiles, but Custom Tilesets are quite well supported by the Google Maps API and there a few good examples out there:
World of Warcraft tileset
Batmud tileset
Tower of the Hand tilset
Update
Google recently announced support for Styled Maps in the Google Maps API. You can extensively customize the color scheme used by Google Maps. So you can customize the look of your mashup, without resorting to custom tilesets.
You can probably change around all the controls, perhaps by making your own or subclassing the google default versions. You won't be able to change the colors on the map itself without generating all new map images, at which point you are probably better off using something other than google. If thats what you want, you should consider OpenStreetMaps.
I've looked into this before. From what I've found is that the styles of layers/overlays on the map are pretty much determined by Google (minus a few size option for some overlays). What I have found is that you'll either need to subclass the existing overlays or create entirely new overlays that mimic the existing functionality, which in some cases can be painful given their complexity (such as street view and others).
Last I checked, you were stuck with the colors you were given (this was a year ago). You can check http://code.google.com/apis/maps/ for more info.