如何使用切换按钮在地图框gl js中突出显示(更改颜色)道路,行人路或自行车道?
答案 0 :(得分:2)
您可以使用setPaintProperty更改图层的填充颜色,就像在此官方Mapbox示例中所做的那样(对于"type": "line"
的图层):
https://www.mapbox.com/mapbox-gl-js/example/color-switcher/
对于line-color
的图层,此PaintProperty将为(* immortal_string.ml *)
external make_string : string -> unit = "make_string"
external get_string : unit -> string = "get_string"
let () = make_string "a"
let () = Gc.full_major ()
let () = Printf.printf "%s\n" (get_string ())
:
https://www.mapbox.com/mapbox-gl-js/style-spec#paint-line-line-color
答案 1 :(得分:0)
var map = new mapboxgl.Map({
...
});
button.onclick = function (e) {
map.setPaintProperty(layer, prepertyName, value);
};