Mapbox - What are my layer ID's? - html

I'm new to using Mapbox.
I'm trying to add a new layer to my map that is above the water layer but below labels.
map.addLayer({
'id': 'maine',
'type': 'fill',
'source': 'maine',
'layout': {},
'paint': {
'fill-color': '#088',
'fill-opacity': 0.8
}
}, 'water');
(This code was taken from some example code from Mapbox.)
Right now, this creates a layer that is below the water layer and the labels. However, I can't figure out what layer ID would bring it above the water layer.
This is the stylesheet I'm using:
mapbox://styles/mapbox/light-v9
How do I find the other valid layer ID's for this style sheet? I've tried 'streets', 'roads', 'road', 'land', etc, but nothing has worked. I thought this link included all the layer names:
https://www.mapbox.com/studio/styles/mapbox/light-v9/
but the only one that keeps my new layer from just being on top of everything is 'water'. Help!

You can retrieve style specifications from the styles api.
For example to get all the layer_ids on the light-v10 style you could do this in python:
import requests
for layer in requests.get('https://api.mapbox.com/styles/v1/mapbox/light-v10?access_token=pk.eyJ1IjoiYmNrb2hhbiIsImEiOiJja2Zvamc4ejcyZjRxMzFwMXNwcGIxdDVlIn0.KdUOuJFIaV4eCzq94AgMGw').json()['layers']: print(layer['id'])
Which yields:
land
landcover
national-park
landuse
water-shadow
waterway
water
hillshade
land-structure-polygon
land-structure-line
aeroway-polygon
aeroway-line
building-outline
building
tunnel-street-minor-low
tunnel-street-minor-case
tunnel-primary-secondary-tertiary-case
tunnel-major-link-case
tunnel-motorway-trunk-case
tunnel-construction
tunnel-path
tunnel-steps
tunnel-major-link
tunnel-pedestrian
tunnel-street-minor
tunnel-primary-secondary-tertiary
tunnel-motorway-trunk
road-pedestrian-case
road-minor-low
road-street-low
road-minor-case
road-street-case
road-secondary-tertiary-case
road-primary-case
road-major-link-case
road-motorway-trunk-case
road-construction
road-path
road-steps
road-major-link
road-pedestrian
road-minor
road-street
road-secondary-tertiary
road-primary
road-motorway-trunk
road-rail
bridge-pedestrian-case
bridge-street-minor-low
bridge-street-minor-case
bridge-primary-secondary-tertiary-case
bridge-major-link-case
bridge-motorway-trunk-case
bridge-construction
bridge-path
bridge-steps
bridge-major-link
bridge-pedestrian
bridge-street-minor
bridge-primary-secondary-tertiary
bridge-motorway-trunk
bridge-rail
bridge-major-link-2-case
bridge-motorway-trunk-2-case
bridge-major-link-2
bridge-motorway-trunk-2
admin-1-boundary-bg
admin-0-boundary-bg
admin-1-boundary
admin-0-boundary
admin-0-boundary-disputed
road-label
waterway-label
natural-line-label
natural-point-label
water-line-label
water-point-label
poi-label
airport-label
settlement-subdivision-label
settlement-label
state-label
country-label
I would just add a note of caution that the layer ids for the default styles can change significantly version to version.

You can experiment in Mapbox.com/studio by adding your maine tile set into a new style, then you can move the layer interactively to experiment and proof the effect that you want.
The second parameter for addLayer is before, so your maine source should've gone before the water layer. See the docs on addLayer for details
https://www.mapbox.com/mapbox-gl-js/api/#Map#addLayer
The names of the layers are identified by "id" in the Style.json.
You can find the names of the layers by going to the link you posted
https://www.mapbox.com/studio/styles/mapbox/light-v9/
there you will see a nice visualization of the layer ids from Mapbox.
The water layer is near the bottom of the layers stack of the Mapbox light style.
Here are the layers with water in the "id.
"id": "waterway-river-canal",
"id": "water shadow",
"id": "water",
"id": "waterway-label",
"id": "water-label",

Your layer ID can be found by opening your map in Mapbox Studio. If you go to View style details (the box with an arrow in the top right corner of the left hand window, it will reveal all the layers.

Related

How do I couple segmented CF traffic data (SS) with shape data (SHP)?

The "Road Shape and Road Class Filters" resource's example seems to imply that CF data is mapped to the current shape. This is because CF and SHP tags are siblings.
<?xml version="1.0" encoding="UTF-8"?>
<TRAFFICML_REALTIME CREATED_TIMESTAMP="2017-06-02T18:10:48Z" MAP_VERSION="" UNITS="imperial" VERSION="3.2" xmlns="http://traffic.nokia.com/trafficml-flow-3.2">
<RWS EBU_COUNTRY_CODE="1" EXTENDED_COUNTRY_CODE="A0" MAP_VERSION="201702" TABLE_ID="7" TY="TMC" UNITS="imperial">
<RW DE="Binford Blvd" LI="107+01100" PBT="2017-06-02T18:10:13Z" mid="1fe417f0-f17e-47b8-b0b0-b67a71eec11d|">
<FIS>
<FI>
<TMC DE="E Kessler Boulevard East Dr" LE="1.5983" PC="8367" QD="-"/>
<SHP FC="3">39.8405,-86.11263 39.84072,-86.11237</SHP>
<SHP FC="3">39.84072,-86.11237 39.8413,-86.11168</SHP>
<SHP FC="3">39.8413,-86.11168 39.84181,-86.11106 39.84235,-86.11039 39.84307,-86.10953 39.84487,-86.10738 39.84663,-86.10527 39.84747,-86.10427 39.84793,-86.10369</SHP>
<SHP FC="3">39.84793,-86.10369 39.84886,-86.10255 39.84949,-86.10172 39.85041,-86.10046 39.85088,-86.09985 39.85137,-86.09926 39.85169,-86.09888 39.85203,-86.09854 39.85237,-86.09821 39.85272,-86.09789 39.85307,-86.09758 39.85343,-86.09729 39.8542,-86.09673 39.85502,-86.09616</SHP>
<SHP FC="3">39.85502,-86.09616 39.85534,-86.09595 39.85631,-86.09528 39.85691,-86.09487 39.85751,-86.09443</SHP>
<SHP FC="3">39.85751,-86.09443 39.85808,-86.09399 39.85836,-86.09379</SHP>
<CF CN="0.97" FF="47.85" JF="1.39455" SP="39.84" SU="39.84" TY="TR"/>
</FI>
<!-- ... -->
</FIS>
</RW>
</RWS>
</TRAFFICML_REALTIME>
This is useful, since it tells me the exact road shape and its corresponding traffic data.
This is not the case when the Flow Item is broken up into multiple segments. Here is a sample JSON that I'm working with:
...
{
"FIS":[
{
"FI":[
{
...
"SHP":[
{
"value":[
"51.24274,7.13212 51.24311,7.13263 51.2432,7.13277 "
],
"FC":3
},
{
"value":[
"51.2432,7.13277 51.24345,7.13314 51.24363,7.13346 51.24382,7.13381 51.24398,7.13408 51.24408,7.13423 51.24418,7.13436 "
],
"FC":3
},
...
]
"CF":[
{
"SSS":{
"SS":[
{
"LE":1.07,
"SP":50.0,
"SU":52.63,
"FF":49.18,
"JF":0.0
},
{
"LE":0.37,
"SP":25.67,
"SU":25.67,
"FF":26.74,
"JF":0.37504
},
...
As you can see, the CF segments are decoupled from the shape of the road, unlike the previous XML example.
Is there any way to interpret this data that couples traffic congestion with the shape of the road?
Each traffic flow model consists of a location data of road segment represented in different location references (TMC, SHP)
and a currentFlow (CF) field describing the current traffic conditions.
If there are different traffic conditions within same road segment, then sub segments (SS) are included to provide more granular traffic conditions while CF having aggregated information.
Data model for traffic flow does not provide location data for each subsegment, however it can be derived using length information available on subsegment SS. Example: Traverse to shape points until it matches subsegment length (preferred using percentile length as length may vary due to different map version or length calculated from shape points does not accurately match with map)then continuing it until last SSS

Modify and Plot overlay using JSON Fabric js

I have generated a JSON file with x, y coordinates to draw polylines using Fabric JS. However, my current problem is the coordinate system that I use is image pixels while the canvas I am drawing is openseadragon (OSD). Therefore, I will need to change the coordinates system from image pixels to viewport coordinate.
I know there is a function in openseadragon imageToViewportCoordinates that may do the conversion. However, the problem is how can I parse out the x , y coordinates, convert them and draw the polylines on fabric js canvas?
The JSON file is as below:
{"version":"2.0.0-beta7","objects":[
{"type":"polyline","fill":"rgba(250,0,0,0.8)","points":[
{"x":61146,"y":155098}
]},
{"type":"polyline","fill":"rgba(250,0,0,0.8)","points":[
{"x":61658,"y":154330}
]},
{"type":"polyline","fill":"rgba(250,0,0,0.8)","points":[
{"x":66778,"y":152538}
]},
{"type":"polyline","fill":"rgba(250,0,0,0.8)","points":[
{"x":67034,"y":152026}
]},
{"type":"polyline","fill":"rgba(250,0,0,0.8)","points":[
{"x":60634,"y":151002},
{"x":60378,"y":151258},
{"x":60122,"y":151258},
{"x":59866,"y":151258},
{"x":59610,"y":151258},
{"x":59354,"y":151514},
{"x":59098,"y":151514},
{"x":58842,"y":151514},
{"x":58586,"y":151770},
{"x":58330,"y":151770},
{"x":58074,"y":152026},
{"x":57818,"y":152282},
{"x":57562,"y":152282},
{"x":57306,"y":152282},
{"x":57306,"y":152538},
{"x":57050,"y":152794},
{"x":56794,"y":152794},
{"x":56538,"y":153050},
{"x":56538,"y":153306},
{"x":56794,"y":153306},
{"x":57050,"y":153306},
{"x":57306,"y":153050},
{"x":57562,"y":152794},
{"x":57818,"y":152794},
{"x":58074,"y":153050},
{"x":58330,"y":153306},
{"x":58586,"y":153562},
{"x":58842,"y":153562},
{"x":59098,"y":153562},
{"x":59354,"y":153306},
{"x":59610,"y":153562},
{"x":59866,"y":153818},
{"x":60122,"y":154074},
{"x":60378,"y":154074},
{"x":60634,"y":154074},
{"x":60890,"y":153818},
{"x":61146,"y":153818},
{"x":61402,"y":153818},
{"x":61146,"y":153562},
{"x":61402,"y":153306},
{"x":61658,"y":153050},
{"x":61914,"y":153306},
{"x":62170,"y":153562},
{"x":62170,"y":153818},
{"x":62426,"y":153818},
{"x":62682,"y":153818},
{"x":62938,"y":154074},
{"x":63194,"y":154074},
{"x":63450,"y":154330},
{"x":63194,"y":154586},
{"x":62938,"y":154586},
{"x":62682,"y":154586},
{"x":62682,"y":154842},
{"x":62426,"y":155098},
{"x":62170,"y":155098},
{"x":61914,"y":155354},
{"x":61914,"y":155610},
{"x":62170,"y":155610},
{"x":62426,"y":155610},
{"x":62682,"y":155866},
{"x":62682,"y":156122},
{"x":62426,"y":156378},
{"x":62682,"y":156634},
{"x":62426,"y":156890},
{"x":62170,"y":156890},
{"x":61914,"y":157146},
{"x":61658,"y":156890},
{"x":61402,"y":156890},
{"x":61146,"y":156634},
{"x":61402,"y":156378},
{"x":61146,"y":156634},
{"x":61146,"y":156890},
{"x":61146,"y":157146},
{"x":61402,"y":156890},
{"x":61658,"y":157146},
{"x":61658,"y":157402},
{"x":61402,"y":157658},
{"x":61146,"y":157914},
{"x":61146,"y":158170},
{"x":60890,"y":158426},
{"x":60634,"y":158682},
{"x":60634,"y":158938},
{"x":60890,"y":159194},
{"x":60890,"y":159450},
{"x":60890,"y":159706},
{"x":60890,"y":159962},
{"x":60890,"y":160218},
{"x":60890,"y":159962},
{"x":60890,"y":159706},
{"x":61146,"y":159450},
{"x":61402,"y":159194},
{"x":61658,"y":158938},
{"x":61914,"y":158682},
{"x":62170,"y":158682},
{"x":62426,"y":158426},
{"x":62682,"y":158682},
{"x":62682,"y":158426},
{"x":62938,"y":158170},
{"x":63194,"y":158170},
{"x":63194,"y":157914},
{"x":63450,"y":157658},
{"x":63706,"y":157658},
{"x":63962,"y":157402},
{"x":64218,"y":157146},
{"x":64474,"y":157146},
{"x":64730,"y":156890},
{"x":64986,"y":156634},
{"x":65242,"y":156634},
{"x":64986,"y":156378},
{"x":65242,"y":156122},
{"x":65242,"y":155866},
{"x":65498,"y":155610},
{"x":65498,"y":155354},
{"x":65498,"y":155098},
{"x":65754,"y":154842},
{"x":65498,"y":154586},
{"x":65498,"y":154330},
{"x":65498,"y":154074},
{"x":65242,"y":153818},
{"x":65242,"y":153562},
{"x":65242,"y":153306},
{"x":64986,"y":153050},
{"x":64986,"y":152794},
{"x":64730,"y":152538},
{"x":64474,"y":152282},
{"x":64218,"y":152026},
{"x":63962,"y":151770},
{"x":63706,"y":151514},
{"x":63706,"y":151258},
{"x":63450,"y":151258},
{"x":63194,"y":151258},
{"x":62938,"y":151002},
{"x":62682,"y":151002},
{"x":62426,"y":151258},
{"x":62170,"y":151514},
{"x":61914,"y":151258},
{"x":61658,"y":151258},
{"x":61402,"y":151002},
{"x":61146,"y":151002},
{"x":60890,"y":151002}
]}]}
Your help is appreciated!
You can change your viewport coordinates to match the coordinates you have in your JSON. For instance if you want the coordinates to stretch from 0 to 61,000, you could do this:
var viewer = OpenSeadragon({
...
tileSources: {
tileSource: url,
width: 61000
}
});

Projecting an Image on Google Map using OpenLayers 3

I am trying to overlay a satellite image (a 6471x7669 jpg file) over Google Map using OL3. The image file's meta-data and projection info is provided as:
Driver: JP2ECW/ERDAS JPEG2000 (SDK 3.x)
Files: /mnt/NAIP/TN/2012/34084/m_3408403_ne_16_1_20120527_20120911.jp2
Size is 6471, 7669
Coordinate System is:
PROJCS["NAD83 / UTM zone 16N",
GEOGCS["NAD83",
DATUM["North_American_Datum_1983",
SPHEROID["GRS 1980",6378137,298.2572221010002,
AUTHORITY["EPSG","7019"]],
AUTHORITY["EPSG","6269"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4269"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",-87],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",500000],
PARAMETER["false_northing",0],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
AUTHORITY["EPSG","26916"]]
Origin = (710739.000000000000000,3875921.000000000000000)
Pixel Size = (1.000000000000000,-1.000000000000000)
Metadata:
COLORSPACE=MULTIBAND
COMPRESSION_RATE_TARGET=9
VERSION=1
Corner Coordinates:
Upper Left ( 710739.000, 3875921.000) ( 84d41'26.44"W, 35d 0'14.31"N)
Lower Left ( 710739.000, 3868252.000) ( 84d41'33.42"W, 34d56' 5.56"N)
Upper Right ( 717210.000, 3875921.000) ( 84d37'11.35"W, 35d 0' 9.39"N)
Lower Right ( 717210.000, 3868252.000) ( 84d37'18.55"W, 34d56' 0.64"N)
Center ( 713974.500, 3872086.500) ( 84d39'22.44"W, 34d58' 7.49"N)
Band 1 Block=256x256 Type=Byte, ColorInterp=Undefined
Description = Band #1
Overviews: 3235x3834, 1617x1917, 808x958, 404x479, 202x239
Band 2 Block=256x256 Type=Byte, ColorInterp=Undefined
Description = Band #2
Overviews: 3235x3834, 1617x1917, 808x958, 404x479, 202x239
Band 3 Block=256x256 Type=Byte, ColorInterp=Undefined
Description = Band #3
Overviews: 3235x3834, 1617x1917, 808x958, 404x479, 202x239
Band 4 Block=256x256 Type=Byte, ColorInterp=Undefined
Description = Band #4
Overviews: 3235x3834, 1617x1917, 808x958, 404x479, 202x239
The problem I'm having is to interpret the data and figure out what projection to use (I'm not a geographer). I have already tested both EPSG:900913 and EPSG:3857 to transform to EPSG:4326, but it doesn't seem to work:
var lonlat = ol.proj.transform(evt.coordinate, 'EPSG:3857', 'EPSG:4326');
The provided data mentions EPSG:7019, EPSG:6269, EPSG:4269, EPSG:9001, and EPSG:26916, none of which seem to have Proj4js definitions. The provided corner & center lat/lons coordinates are pretty accurate.
My questions are: is there an existing proj4.defs for this? If not, how can I create one? Any help on this is greatly appreciated.
UPDATE
Expanding on this question further: Initially we center the static image over Google Map just fine.
But not sure what transformation to use as the layers are moved together. In a nutshell what should be the transformation <transform> in this code?
view.on('change:center', function() {
var center = ol.proj.transform(view.getCenter(), <transform>, 'EPSG:4326');
gmap.setCenter(new google.maps.LatLng(center[1], center[0]))
});
You source image is in NAD83 UTM 16N or EPSG:26916 see http://spatialreference.org/ref/epsg/nad83-utm-zone-16n/
UTM is a Transverse Mercator projection with vertical 6 degree strips of the world projected onto a cylinder with its axis through the poles. Google maps uses a spherical Mercator (horizontal cylindrical) projection - EPSG:3857. The properties of these two are quite different - you will not be able to accurately overlay your 26916 image on a 3857 map without reprojecting it.
Have you looked at this http://openlayers.org/en/latest/examples/reprojection-image.html ?
Alternatively, you could use a GIS program of some sort to re-project your image to 3857 for easier composition with a 3857 map - say something like GlobalMapper.

Google Map API Marker Icon Url?

I'm trying to change marker icon to "red-circle" or "red-pin" or anything else.
In these codes;
markerOptions: {
icon: 'images/beachflag.png'
},
the marker doesn't show. But if i make the icon line a comment line, so marker shows like "red-pin" icon
So, i need to marker icons list or URL list which directly supported by Google Map API. Or is there such a thing?
Thank you.
This is the (unofficial) list that I refer to:
https://groups.google.com/d/msg/Google-Maps-API/2k3T5hwI5Ck/RRso0D2jB1oJ
provided by pamela (who was a Google employee at the time), it is fairly old, but still accurate.
=================== -- ============================
-- from Mike Williams --
It's also worth noting that only the original set of icons is available
in the location that was mentioned earlier in this thread
E.g. blue.png is available at both locations
http://maps.google.com/mapfiles/ms/icons/blue.png
http://maps.google.com/mapfiles/ms/micons/blue.png
But the new yen.png icon is only here
http://maps.google.com/mapfiles/ms/micons/yen.png
-- from pamela --
I'll provide the list to you here, but you should know it's possible
some of these icons will disappear later. You may want to copy to your
own server to be sure.
Happy reading... :)
POI.png
POI.shadow.png
arts.png
arts.shadow.png
bar.png
bar.shadow.png
blue-dot.png
blue-pushpin.png
blue.png
bus.png
bus.shadow.png
cabs.png
cabs.shadow.png
camera.png
camera.shadow.png
campfire.png
campfire.shadow.png
campground.png
campground.shadow.png
caution.png
caution.shadow.png
coffeehouse.png
coffeehouse.shadow.png
convienancestore.png
convienancestore.shadow.png
cycling.png
cycling.shadow.png
dollar.png
dollar.shadow.png
drinking_water.png
drinking_water.shadow.png
earthquake.png
earthquake.shadow.png
electronics.png
electronics.shadow.png
euro.png
euro.shadow.png
fallingrocks.png
fallingrocks.shadow.png
ferry.png
ferry.shadow.png
firedept.png
firedept.shadow.png
fishing.png
fishing.shadow.png
flag.png
flag.shadow.png
gas.png
gas.shadow.png
golfer.png
golfer.shadow.png
green-dot.png
green.png
grn-pushpin.png
grocerystore.png
grocerystore.shadow.png
groecerystore.png
groecerystore.shadow.png
helicopter.png
helicopter.shadow.png
hiker.png
hiker.shadow.png
homegardenbusiness.png
homegardenbusiness.shadow.png
horsebackriding.png
horsebackriding.shadow.png
hospitals.png
hospitals.shadow.png
hotsprings.png
hotsprings.shadow.png
info.png
info.shadow.png
info_circle.png
info_circle.shadow.png
landmarks-jp.png
landmarks-jp.shadow.png
lightblue.png
lodging.png
lodging.shadow.png
ltblu-pushpin.png
ltblue-dot.png
man.png
man.shadow.png
marina.png
marina.shadow.png
mechanic.png
mechanic.shadow.png
motorcycling.png
motorcycling.shadow.png
movies.png
movies.shadow.png
msmarker.shadow.png
orange-dot.png
orange.png
parkinglot.png
parkinglot.shadow.png
partly_cloudy.png
partly_cloudy.shadow.png
pharmacy-us.png
pharmacy-us.shadow.png
phone.png
phone.shadow.png
picnic.png
picnic.shadow.png
pink-dot.png
pink-pushpin.png
pink.png
plane.png
plane.shadow.png
police.png
police.shadow.png
postoffice-jp.png
postoffice-jp.shadow.png
postoffice-us.png
postoffice-us.shadow.png
purple-dot.png
purple-pushpin.png
purple.png
pushpin_shadow.png
question.png
question.shadow.png
rail.png
rail.shadow.png
rainy.png
rainy.shadow.png
rangerstation.png
rangerstation.shadow.png
realestate.png
realestate.shadow.png
recycle.png
recycle.shadow.png
red-dot.png
red-pushpin.png
red.png
restaurant.png
restaurant.shadow.png
sailing.png
sailing.shadow.png
salon.png
salon.shadow.png
shopping.png
shopping.shadow.png
ski.png
ski.shadow.png
snack_bar.png
snack_bar.shadow.png
snowflake_simple.png
snowflake_simple.shadow.png
sportvenue.png
sportvenue.shadow.png
subway.png
subway.shadow.png
sunny.png
sunny.shadow.png
swimming.png
swimming.shadow.png
toilets.png
toilets.shadow.png
trail.png
trail.shadow.png
tram.png
tram.shadow.png
tree.png
tree.shadow.png
truck.png
truck.shadow.png
volcano.png
volcano.shadow.png
water.png
water.shadow.png
waterfalls.png
waterfalls.shadow.png
webcam.png
webcam.shadow.png
wheel_chair_accessible.png
wheel_chair_accessible.shadow.png
woman.png
woman.shadow.png
yellow-dot.png
yellow.png
yen.png
yen.shadow.png
ylw-pushpin.png

Higstock add all series dynamically

I've a Higstock lineal graph. Sometimes I need to show just one serie, other times I need two or three series to draw.
Obviously, this is an example of adding series dynamically. I put:
$(function() {
var chart = new Highcharts.StockChart({
// ...
series: []
// ...
})
chart.addSeries({name : "Value1",data : value1Data});
chart.addSeries({name : "Value2",data : value2Data});
chart.addSeries({name : "Value3",data : value3Data});
But not working, the chart needs to have at least one serie with data values in "series" node, not allowing an empty series node, like I put before.
I need to add all my series dynamically.
Anyone can help me? Thanks.
Example: http://jsfiddle.net/8aP69/1/
FYI: The graph only draws the navigation bar.
After many little test, a man that I loved him give me the solution.
I need to set initial series node like that:
series: [{ name: "Serie1", data : [null]}] // first serie has to be null
And after that, adding data point for first serie.
chart.series[0].setData(data1); // adding his data here