How do I add a scale bar or north arrow directly on the map control? - arcobjects

I've already looked into SurroundFrames and MapSurrounds, but this appears to be for cases in which you want to add these elements to a printed page. I, on the other hand, am using the MapControl within a live application, and I would like these element directly on the map, in the same way you see them on Google Maps.
Do I have to add these things from scratch using custom symbols and capturing events, or does ArcObjects automate this in any way?

The PageLayoutControl is designed to do this. Scale bars, legends, north arrow, map insets, titles, overview maps, etc. are all layout elements.

Related

Two cursors on maps at same time in Mapbox GL-JS

I am developing a weather radar viewer using Mapbox. In a certain mode, there are 2 Mapbox maps on the screen at the same time showing different modes of the radar. The maps are locked to each other. When one map moves, rotates, or pans - the other one does as well. I did this by simply passing the properties of one map to the other. In the below screenshot, you will see how they are showing identical locations.
What I want to do is - when the user is hovering the mouse over "map1", I would like an identical (ghost or false) cursor on "map2". Here is what I am looking to do:
(edit: What you are looking at is an actual screenshot. Each map is enclosed in a DIV with 50% width of the screen, if this helps to explain)
I don't know if this is even possible in Mapbox. Hopefully someone can give some guidance as I can't find any other questions related to this and I really have no code to show without knowing where to start.
If you attempt to do this inside Mapbox-GL-JS (for instance, by constantly updating the location of a GeoJSON feature layer), I think the performance will be pretty poor.
But since the two views are exactly locked (and presumably the exact same dimensions), you can just do this at an HTML/CSS level. Detect mouse movement on the first map, and update the location of an absolutely-positioned element hovering over the second map to match.
Another approach would be using a canvas element overlaid over the second map, similarly updated.

possible to show road-path-smooth items at lower zoom levels

I'd like for my road-path-smooth elements to show at a lower zoom level than they currently are because my application is for the outdoors and these are more important elements. Is that possible? I can't seem to find out how to adjust this in studio.
If you're talking about displaying layers from the Mapbox Streets tileset, then no, it's probably not possible. The vector tiles are optimised for Mapbox's style (also, confusingly, called Mapbox Streets), and don't contain data that isn't already displayed.
Your need is a common one, but unfortunately the only way to solve it is to find a different set of vector tiles that meets your needs, or create one yourself.

How to write text onto a mapbox vector tile

I want to label stations on my map, and I would like to clusterize the stops at different zoom levels to filter them down. So as you zoom out all you get is the start and end, and then finally a single label start->end.
How do I render a text label on a vector tile ?
I could fetch the stations as a geojson and reload on zoom change if there's no easy way to do this with tiles.
Is there a reason you need to encode your data differently per-zoom-level in the tiles or are you mainly concerned with displaying data differently per-zoom-level? If the latter, I would recommend looking for an approach that focuses more on styling the vector tiles you already have rather than trying to generate those tiles in a more complex fashion. You could try using a zoom function to style your data. If you're using Mapbox Studio, you can also set zoom-specific style rules in the Studio UI, which is the route you'll probably want to go if you're using Leaflet (I see the Leaflet tag in your post but it's not entirely clear what your implementation looks like).
If the former, you may need to use a tool like Tippecanoe. This route will likely be a bit more complex, but gives you fine-grained control over how your vector tiles are generated. Keep in mind that once you've created your tiles using Tippecanoe, you'll still need to style them somehow.

Style and display buildings

I want to create a static google maps image which displays buildings (and buildings only). I looked through the Styled Maps page on static maps stylings, but I couldn't find an option for buildings in particular.
Please note that this should also work in less populated areas, so simply turning the landscape one colour and showing the roads in another does not suffice (like done in this image).
Is there a way to create such a map?
The closest feature for buildings would be the landscape.man_made feature which selects structures built by humans. You can also experiment on other features that may suite your needs such as points of interest.
For features that you want to hide from the map, you can set the style to visibility:off for that specific feature.
Here's an example that changes the stroke color for all man made landscapes and hides all roads:
https://maps.googleapis.com/maps/api/staticmap?size=512x512&zoom=17&center=Brooklyn&style=feature:landscape.man_made|element:geometry.stroke|color:0xff0000&style=feature:road|visibility:off&key=YOUR_API_KEY
Note that the sample uses the element geometry.stroke which selects only the stroke of the feature's geometry.
Hope this helps!

Mapbox: show only one country on base map?

I'm using Mapbox GL JS. Is there any way I can style my base layer to look like the Mapbox Light example, but showing only the UK?
I assume I would use Mapbox Studio to build my own base layer, but I can't see any way in Studio to filter by country.
If that's not possible, is there any way I could show labels on the UK only, and show other countries as filled polygons? (As per this unanswered question.)
Unfortunately it is not possible to filter by a certain geography when selecting the data source for a layer. If you're working with Mapbox's tiles, they'll always cover the entire planet.
There is the possibility to restrict the map to a certain (rectangular) bounds, with the map.setMaxBounds method (https://www.mapbox.com/mapbox-gl-js/api/#Map#setMaxBounds). This might work reasonably well since you want to restrict the view to the UK, but might not be suitable depending on the geometry you want to restrict the view to.
As a workaround you could create a dataset and add a polygon that covers the entire planet except for the extent you want to show in your map. Then add this dataset in your style as the top most layer and style it with whatever you'd like the empty space in your map to look like.
The workaround has been also suggested in this SO answer, if you can get maptiles for the UK only (the SO answer gives a link, but for Germany) you can
upload them to Mapbox as a dataset, export it to tilesets, and then
to a map as a layer. Delete all other layers
You have also the possibility to Style a single country in Mapbox
studio ref this tutorial. The other countries are still shown, but you can style your map in a way to highlight UK
There is a option that allows you to show only one country highlighted. But drawback is, you lose all the layers and tile-level details. Here is the link https://www.mapbox.com/videos/how-to/map-a-single-country-in-mapbox-studio/.
But if you want to include the tile details as well as whole world map but in that map only one or two or custom amount of countries highlighted, then, from above link of Natural Earth download the zipped file of ne_10m_admin_0_countries and upload.
Go back to your map style, and instead of making a blank one. Add another layer of ne_10m_admin_0_countries in your current map. Select the country in the filter option (in same way as shown in video). And change its opacity. That's it.
Hope it helps. Have a great day.