Showing the name of a polygon along the edge of that polygon - leaflet

In the following picture there's a line and on one side of it it says "United States" and on the other side it says "Mexico". And both words are parallel to that line.
My question is... how can I achieve a similar effect with leafletjs?

Related

Make contour labels point uphill: reverse direction of text label on line feature

I am designing a map in Mapbox Studio, using mapbox.mapbox-terrain-v2’s contour layer to determine the contour lines. This is based on the outdoors style.
In the outdoors style, the contour labels are oriented so that the text is displayed between -90° and 90° of horizontal, because Keep Text Upright is set. If I disable this, then the text becomes oriented at any angle. However, this text is oriented at exactly the opposite angle to what I would like: it always points downhill, not uphill. See first image below: note that the numbers are upright where the elevation increases from north to south.
What I am aiming for is to use the Ordnance Survey style of orienting numbers uphill (upright where the elevation increases from south to north), as in the second image below.
My current style can be seen here. I have tried using the text-rotate field, but this rotates each character individually, and there does not appear to be a function to reverse the string to counteract this. Additionally, this rotates about the top of each letter, meaning that the result is offset from the actual contour line, and text-translate + text-translate-anchor seem unable to resolve this.
As you noticed, using text-rotate on a symbol layer with placement: line rotates each character individually. So you would need to then reverse the string, which isn't possible within the expressions available.
However. There is one hacky workaround which may solve the problem for you. You can simply hardcode all the possible elevations with their reversals:
["match", ["get", "ele"],
750, "m057",
700, "m007",
650, "m056",
600, "m006",
550, "m055",
500, "m005",
""
]
Combined with a text-offset of 0,1.5, this actually looks alright:
I've published the style here

Way of formatting Word so that a line occur at a given distance from page border?

I don't know how to properly specify this question, but basically I would like to format a document like specified here : http://etd.lib.hku.hk/thesis-form/Theses%20Binding%20specification(ed%20January%202018)c.pdf
It's on the 3rd page of the PDF document. So I need to input a line at the exact distance from the top border, while another line occurs at some exact distance from the bottom.
Does MS Word give the flexibility to do this?
Thanks!
Someone points out this question is off-topic for this forum but just in case someone is here anyway: use multiple text boxes can be the solution.
A user can adjust a text box's relative position on a page and thus achieve the formatting needed.

Colorizing russian map with leaflet

I'd like to colorize russian map with leaflet.But there is a problem with a region (Chukotka Autonomous Okrug), that is placed on the "bend" line of the map. Part of the region appears on the other part of the map (here's a link to the picture http://i.stack.imgur.com/cQSlG.png). I've already tried to use noWrap option, but it didn't help. Any help will be highly appreciated!
That happens when you cross the international dataline. What you want can be done but you've got to edit your geometries. In your case you would need to add 360 to every coordinate you encounter that's left of the prime meridian, thus every negative longitude. Mapbox has a nice example on the matter:
https://www.mapbox.com/mapbox.js/example/v1.0.0/cross-date-line/

Place a marker in each country with mapbox

I am using Mapbox to build a multiple choropleth map.
Something along the lines of this example, https://www.mapbox.com/mapbox.js/example/v1.0.0/choropleth-joined-data-multiple-variables/
I am using countries instead of US states however.
I've got the map working and I can switch between layers
I have an extra requirement however to add a marker in each country that displays how many projects are active in that country.
I found out how I can add custom markers to the map with this example, https://www.mapbox.com/mapbox.js/example/v1.0.0/divicon/
The problem is I need to put a marker in the center of each country.
Does anybody know a way to put a marker in the middle of each country?
I tried to use the natural earth admin 0 label points data but that has multiple points per country. It looked like the 'scalerank=0' points were the middle of the countries but if I filter on these points, I still get multiple points for some countries (russia has 4 for instance, but Belgium has 4 as well).
If you plot all scalerank 0 points on a map you get the following result:
https://a.tiles.mapbox.com/v4/persyval.jg5p7gm7/page.html?access_token=pk.eyJ1IjoicGVyc3l2YWwiLCJhIjoiX3lrSTNYYyJ9.6Ps4OlBCYmlkxQksKsGb7A#6/45.159/12.206
Does anybody know about a dataset that has one point per country or another way to put a marker in the center of each country with mapbox?
It seems it's hard to find a list of country points for the placing of markers.
So I took the mentioned admin labal 0 points and tried to sanitize it to have only one appropiate marker per country.
The result can be downloaded here in GEOJSON format:
https://drive.google.com/file/d/0B6IQhfb-UYeUYk1mcUZaMmV0S1U/edit?usp=sharing
If you want to have a visual representation of the points take a look at this map:
https://a.tiles.mapbox.com/v4/persyval.jgk4767c/page.html?access_token=pk.eyJ1IjoicGVyc3l2YWwiLCJhIjoiX3lrSTNYYyJ9.6Ps4OlBCYmlkxQksKsGb7A#4/36.49/34.32
I needed this points for a proof of concept project so I haven't checked all markers meticulously, I also haven't taken account some of the more political sensitive country borders.
If you have a project in which this is of importance please check the file before using, but the points in this file can be easily edited to your own preferences.

Latlonaltbox for an entire country

I'm trying to create a region which covers Sweden.
In the Region i placed a LatLonAltBox but I'm not sure what coordinates to put in.
I've read the KML Reference guide on developer.google.com but it didn't make me any wiser.
Can someone explain how to look up the coordinates and show which coordinate goes where.
<LatLonBox>
<north>90.0</north>
<south>-90.0</south>
<west>-180.0</west>
<east>180.0</east>
</LatLonBox>
The <LatLonAltBox> should contain the max and min bounds for the given region such that north is the northern-most latitude, south is the southern-most latitude, east is the eastern-most longitude, and west is the western-most longitude.
There are two ways to create a Region for a given area or country:
1) One way is to open the world country KML overlay in Google Earth then copy the country feature (E.g. Sweden). This approach will extract the exact coordinates of the region.
World Countries as Polygons. Next generation
https://productforums.google.com/d/msg/gec-tools/rNjNRYbaWSI/5x5vfgxc0w0J
To copy the Sweden geometry, press Ctrl-F to search for Sweden then right-mouse click on the placemark and select 'Copy'. This copies the KML into the clipboard.
Next visit the Bounding Box tool and paste the polygon for Sweden into the text box.
The generated line marks the 4-corner boundary points of Sweden in longitude-latitude pairs:
<coordinates>
11.11333,55.34,0
11.11333,69.0603,0
24.16701,69.0603,0
24.16701,55.34,0
11.11333,55.34,0
</coordinates>
To make it readable you should insert new lines after each longitude-latitude pair. Now pick the largest and smallest longitude: 24.16701, 11.11 and largest/smallest latitude values: 69.0603, 55.34.
Next, insert those values in appropriate tags in LatLonAltBox element as shown below:
<Region>
<LatLonAltBox>
<north>69.0603</north>
<south>55.34</south>
<west>24.16701</west>
<east>11.11</east>
</LatLonAltBox>
</Region>
2) To create an arbitrary region In Google Earth there is a trick to create an ImageOverlay over the particular region on the map. Follow these steps:
In Add menu, click 'Image Overlay'.
Click 'Browse...' and pick any image
Stretch the image to cover the bounds of the particular
region. NOTE: You may have to make the image semi-transparent to
see the underlying map.
Click Location tab to see the bounds of the
region.
When done click "OK" to save the image overlay.
Right-mouse click on the created image overlay, select "copy", and
paste KML into a text editor.
The <LatLonBox> of the GroundOverlay (aka ImageOverlay) will be the values needed for a
Region's LatLonAltBox. Rename element LatLonBox to LatLonAltBox and
copy/paste into the Region of your target KML.