How to show/hide raster layer (visibility property visible/none) at run time in react-native-mapbox-glHow to add markers / annotations programatically with mapbox and react nativeHow do you debug React Native?Hide keyboard in react-nativeHow to do logging in React Native?Hide/Show components in react nativeHow to add icons to React Native appError Running React Native App From Terminal (iOS)How to programatically add a raster layer to mapbox react native?How to work with mapbox marker clustors in react native?How to place a floating button in react native mapbox GLdetox e2e testing with react native mapbox gl
How can ping know if my host is down
Why does this expression simplify as such?
How do I fix the group tension caused by my character stealing and possibly killing without provocation?
Stack Interview Code methods made from class Node and Smart Pointers
What does Apple's new App Store requirement mean
"It doesn't matter" or "it won't matter"?
What are some good ways to treat frozen vegetables such that they behave like fresh vegetables when stir frying them?
How do you make your own symbol when Detexify fails?
15% tax on $7.5k earnings. Is that right?
What's the name of the logical fallacy where a debater extends a statement far beyond the original statement to make it true?
Creating two special characters
awk assign to multiple variables at once
How can I write humor as character trait?
Why is the "ls" command showing permissions of files in a FAT32 partition?
Which Article Helped Get Rid of Technobabble in RPGs?
Does "he squandered his car on drink" sound natural?
Does the Linux kernel need a file system to run?
Shouldn’t conservatives embrace universal basic income?
What fields between the rationals and the reals allow a good notion of 2D distance?
Change the color of a single dot in `ddot` symbol
The IT department bottlenecks progress, how should I handle this?
Why is it that I can sometimes guess the next note?
How could a planet have erratic days?
Mimic lecturing on blackboard, facing audience
How to show/hide raster layer (visibility property visible/none) at run time in react-native-mapbox-gl
How to add markers / annotations programatically with mapbox and react nativeHow do you debug React Native?Hide keyboard in react-nativeHow to do logging in React Native?Hide/Show components in react nativeHow to add icons to React Native appError Running React Native App From Terminal (iOS)How to programatically add a raster layer to mapbox react native?How to work with mapbox marker clustors in react native?How to place a floating button in react native mapbox GLdetox e2e testing with react native mapbox gl
I have set custom style url in map initialization. Like :
<Mapbox.MapView
styleURL="asset://mystyle.json"
logoEnabled=false
attributionEnabled=false
ref=(e) => this.oMap = e
animate=true
zoomLevel=6
centerCoordinate=[54.0, 24.0]
style= flex: 1
showUserLocation=true>
</Mapbox.MapView>
In mystyle.json I have two base map as below :
"id": "Satellite",
"type": "raster",
"source": "Satellite",
"layout":
"visibility": "visible"
,
"paint":
"raster-opacity": 1
,
"id": "Satellite2",
"type": "raster",
"source": "Satellite",
"layout":
"visibility": "none"
,
"paint":
"raster-opacity": 1
Satellite is visible default.
How to set visibility of satellite property to none and satellite2 visibility to visible at run time?
Mapbox gl :
"@mapbox/react-native-mapbox-gl": "^6.1.3"
React native :
"react-native": "0.58.6",
react-native react-native-mapbox-gl
add a comment |
I have set custom style url in map initialization. Like :
<Mapbox.MapView
styleURL="asset://mystyle.json"
logoEnabled=false
attributionEnabled=false
ref=(e) => this.oMap = e
animate=true
zoomLevel=6
centerCoordinate=[54.0, 24.0]
style= flex: 1
showUserLocation=true>
</Mapbox.MapView>
In mystyle.json I have two base map as below :
"id": "Satellite",
"type": "raster",
"source": "Satellite",
"layout":
"visibility": "visible"
,
"paint":
"raster-opacity": 1
,
"id": "Satellite2",
"type": "raster",
"source": "Satellite",
"layout":
"visibility": "none"
,
"paint":
"raster-opacity": 1
Satellite is visible default.
How to set visibility of satellite property to none and satellite2 visibility to visible at run time?
Mapbox gl :
"@mapbox/react-native-mapbox-gl": "^6.1.3"
React native :
"react-native": "0.58.6",
react-native react-native-mapbox-gl
add a comment |
I have set custom style url in map initialization. Like :
<Mapbox.MapView
styleURL="asset://mystyle.json"
logoEnabled=false
attributionEnabled=false
ref=(e) => this.oMap = e
animate=true
zoomLevel=6
centerCoordinate=[54.0, 24.0]
style= flex: 1
showUserLocation=true>
</Mapbox.MapView>
In mystyle.json I have two base map as below :
"id": "Satellite",
"type": "raster",
"source": "Satellite",
"layout":
"visibility": "visible"
,
"paint":
"raster-opacity": 1
,
"id": "Satellite2",
"type": "raster",
"source": "Satellite",
"layout":
"visibility": "none"
,
"paint":
"raster-opacity": 1
Satellite is visible default.
How to set visibility of satellite property to none and satellite2 visibility to visible at run time?
Mapbox gl :
"@mapbox/react-native-mapbox-gl": "^6.1.3"
React native :
"react-native": "0.58.6",
react-native react-native-mapbox-gl
I have set custom style url in map initialization. Like :
<Mapbox.MapView
styleURL="asset://mystyle.json"
logoEnabled=false
attributionEnabled=false
ref=(e) => this.oMap = e
animate=true
zoomLevel=6
centerCoordinate=[54.0, 24.0]
style= flex: 1
showUserLocation=true>
</Mapbox.MapView>
In mystyle.json I have two base map as below :
"id": "Satellite",
"type": "raster",
"source": "Satellite",
"layout":
"visibility": "visible"
,
"paint":
"raster-opacity": 1
,
"id": "Satellite2",
"type": "raster",
"source": "Satellite",
"layout":
"visibility": "none"
,
"paint":
"raster-opacity": 1
Satellite is visible default.
How to set visibility of satellite property to none and satellite2 visibility to visible at run time?
Mapbox gl :
"@mapbox/react-native-mapbox-gl": "^6.1.3"
React native :
"react-native": "0.58.6",
react-native react-native-mapbox-gl
react-native react-native-mapbox-gl
edited Mar 7 at 6:27
Khurshid Ansari
asked Mar 7 at 5:03
Khurshid AnsariKhurshid Ansari
672617
672617
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
let say we have one state isStateliteVisible:false
,
now change this state to true
when you want to visibility
and use mapbox like this,
<Mapbox.MapView
styleURL=this.state.isStateliteVisible?...visiblityStyle:....noneStyle // use this as per your case
logoEnabled=false
attributionEnabled=false
ref=(e) => this.oMap = e
animate=true
zoomLevel=6
centerCoordinate=[54.0, 24.0]
style= flex: 1
showUserLocation=true>
</Mapbox.MapView>
Thanks for your logic but I have more than 2 layers which i want to show and hide programmatically.
– Khurshid Ansari
Mar 7 at 6:59
you mean more than two style to single map or more than two maps ?
– Jaydeep Galani
Mar 7 at 7:00
I have 3 base maps. and many layers
– Khurshid Ansari
Mar 7 at 7:01
I have done using mapbox-gl-js like this.oMap.setLayoutProperty("layerid", 'visibility', 'none'); for my website and looking for same in react-native-mapbox-gl
– Khurshid Ansari
Mar 7 at 7:03
hope you understand my situation
– Khurshid Ansari
Mar 7 at 7:36
|
show 3 more comments
I can see that you are using a older depreciated version of mapbox-gl.
This package is deprecated please use this instead.
Installation
Dependencies
node
npm
React Native recommended version 0.50 or greater
Git
git clone git@github.com:mapbox/react-native-mapbox-gl.git
cd react-native-mapbox-gl
Yarn
yarn add @mapbox/react-native-mapbox-gl
Npm
npm install @mapbox/react-native-mapbox-gl --save
You're good to go!
I am using latest version.
– Khurshid Ansari
Mar 7 at 5:18
Do you know how to change layer visibility at run time?
– Khurshid Ansari
Mar 7 at 5:20
See github.com/agius/react-native-mapbox-gl/blob/master/docs/… but I don't know how to change visibility at runtime.
– Khurshid Ansari
Mar 7 at 5:35
docs.mapbox.com/help/troubleshooting/mapbox-gl-js-performance/…. Please check this. i think this might help @KhurshidAnsari
– Akshay Mulgavkar
Mar 7 at 5:59
This is mapbox gl js
– Khurshid Ansari
Mar 7 at 6:10
add a comment |
Finally I got solution :
constructor()
this.state =
lightMap: 'visible',
darkMap: 'none'
;
changeMap()
this.setState(darkMap:'visible')
<MapboxGL.MapView
styleURL="asset://mystyle.json"
logoEnabled=false
attributionEnabled=false
ref=(e) => this.oMap = e
zoomLevel=6
centerCoordinate=[54.0, 24.0]
style= flex: 1 >
<MapboxGL.RasterSource
id="idLightMap"
url="LAYERURL1"
tileSize=256>
<MapboxGL.RasterLayer
id="idLightMap"
sourceID="idLightMap"
style=visibility: this.state.lightMap>
</MapboxGL.RasterLayer>
</MapboxGL.RasterSource>
<MapboxGL.RasterSource
id="idDarkMap"
url="LAYERURL2"
tileSize=256>
<MapboxGL.RasterLayer
id="idDarkMap"
sourceID="idDarkMap"
style=visibility: this.state.darkMap>
</MapboxGL.RasterLayer>
</MapboxGL.RasterSource>
</MapboxGL.MapView>
I have added raster layer and programmatic toggling it.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55036420%2fhow-to-show-hide-raster-layer-visibility-property-visible-none-at-run-time-in%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
let say we have one state isStateliteVisible:false
,
now change this state to true
when you want to visibility
and use mapbox like this,
<Mapbox.MapView
styleURL=this.state.isStateliteVisible?...visiblityStyle:....noneStyle // use this as per your case
logoEnabled=false
attributionEnabled=false
ref=(e) => this.oMap = e
animate=true
zoomLevel=6
centerCoordinate=[54.0, 24.0]
style= flex: 1
showUserLocation=true>
</Mapbox.MapView>
Thanks for your logic but I have more than 2 layers which i want to show and hide programmatically.
– Khurshid Ansari
Mar 7 at 6:59
you mean more than two style to single map or more than two maps ?
– Jaydeep Galani
Mar 7 at 7:00
I have 3 base maps. and many layers
– Khurshid Ansari
Mar 7 at 7:01
I have done using mapbox-gl-js like this.oMap.setLayoutProperty("layerid", 'visibility', 'none'); for my website and looking for same in react-native-mapbox-gl
– Khurshid Ansari
Mar 7 at 7:03
hope you understand my situation
– Khurshid Ansari
Mar 7 at 7:36
|
show 3 more comments
let say we have one state isStateliteVisible:false
,
now change this state to true
when you want to visibility
and use mapbox like this,
<Mapbox.MapView
styleURL=this.state.isStateliteVisible?...visiblityStyle:....noneStyle // use this as per your case
logoEnabled=false
attributionEnabled=false
ref=(e) => this.oMap = e
animate=true
zoomLevel=6
centerCoordinate=[54.0, 24.0]
style= flex: 1
showUserLocation=true>
</Mapbox.MapView>
Thanks for your logic but I have more than 2 layers which i want to show and hide programmatically.
– Khurshid Ansari
Mar 7 at 6:59
you mean more than two style to single map or more than two maps ?
– Jaydeep Galani
Mar 7 at 7:00
I have 3 base maps. and many layers
– Khurshid Ansari
Mar 7 at 7:01
I have done using mapbox-gl-js like this.oMap.setLayoutProperty("layerid", 'visibility', 'none'); for my website and looking for same in react-native-mapbox-gl
– Khurshid Ansari
Mar 7 at 7:03
hope you understand my situation
– Khurshid Ansari
Mar 7 at 7:36
|
show 3 more comments
let say we have one state isStateliteVisible:false
,
now change this state to true
when you want to visibility
and use mapbox like this,
<Mapbox.MapView
styleURL=this.state.isStateliteVisible?...visiblityStyle:....noneStyle // use this as per your case
logoEnabled=false
attributionEnabled=false
ref=(e) => this.oMap = e
animate=true
zoomLevel=6
centerCoordinate=[54.0, 24.0]
style= flex: 1
showUserLocation=true>
</Mapbox.MapView>
let say we have one state isStateliteVisible:false
,
now change this state to true
when you want to visibility
and use mapbox like this,
<Mapbox.MapView
styleURL=this.state.isStateliteVisible?...visiblityStyle:....noneStyle // use this as per your case
logoEnabled=false
attributionEnabled=false
ref=(e) => this.oMap = e
animate=true
zoomLevel=6
centerCoordinate=[54.0, 24.0]
style= flex: 1
showUserLocation=true>
</Mapbox.MapView>
answered Mar 7 at 6:55
Jaydeep GalaniJaydeep Galani
7511429
7511429
Thanks for your logic but I have more than 2 layers which i want to show and hide programmatically.
– Khurshid Ansari
Mar 7 at 6:59
you mean more than two style to single map or more than two maps ?
– Jaydeep Galani
Mar 7 at 7:00
I have 3 base maps. and many layers
– Khurshid Ansari
Mar 7 at 7:01
I have done using mapbox-gl-js like this.oMap.setLayoutProperty("layerid", 'visibility', 'none'); for my website and looking for same in react-native-mapbox-gl
– Khurshid Ansari
Mar 7 at 7:03
hope you understand my situation
– Khurshid Ansari
Mar 7 at 7:36
|
show 3 more comments
Thanks for your logic but I have more than 2 layers which i want to show and hide programmatically.
– Khurshid Ansari
Mar 7 at 6:59
you mean more than two style to single map or more than two maps ?
– Jaydeep Galani
Mar 7 at 7:00
I have 3 base maps. and many layers
– Khurshid Ansari
Mar 7 at 7:01
I have done using mapbox-gl-js like this.oMap.setLayoutProperty("layerid", 'visibility', 'none'); for my website and looking for same in react-native-mapbox-gl
– Khurshid Ansari
Mar 7 at 7:03
hope you understand my situation
– Khurshid Ansari
Mar 7 at 7:36
Thanks for your logic but I have more than 2 layers which i want to show and hide programmatically.
– Khurshid Ansari
Mar 7 at 6:59
Thanks for your logic but I have more than 2 layers which i want to show and hide programmatically.
– Khurshid Ansari
Mar 7 at 6:59
you mean more than two style to single map or more than two maps ?
– Jaydeep Galani
Mar 7 at 7:00
you mean more than two style to single map or more than two maps ?
– Jaydeep Galani
Mar 7 at 7:00
I have 3 base maps. and many layers
– Khurshid Ansari
Mar 7 at 7:01
I have 3 base maps. and many layers
– Khurshid Ansari
Mar 7 at 7:01
I have done using mapbox-gl-js like this.oMap.setLayoutProperty("layerid", 'visibility', 'none'); for my website and looking for same in react-native-mapbox-gl
– Khurshid Ansari
Mar 7 at 7:03
I have done using mapbox-gl-js like this.oMap.setLayoutProperty("layerid", 'visibility', 'none'); for my website and looking for same in react-native-mapbox-gl
– Khurshid Ansari
Mar 7 at 7:03
hope you understand my situation
– Khurshid Ansari
Mar 7 at 7:36
hope you understand my situation
– Khurshid Ansari
Mar 7 at 7:36
|
show 3 more comments
I can see that you are using a older depreciated version of mapbox-gl.
This package is deprecated please use this instead.
Installation
Dependencies
node
npm
React Native recommended version 0.50 or greater
Git
git clone git@github.com:mapbox/react-native-mapbox-gl.git
cd react-native-mapbox-gl
Yarn
yarn add @mapbox/react-native-mapbox-gl
Npm
npm install @mapbox/react-native-mapbox-gl --save
You're good to go!
I am using latest version.
– Khurshid Ansari
Mar 7 at 5:18
Do you know how to change layer visibility at run time?
– Khurshid Ansari
Mar 7 at 5:20
See github.com/agius/react-native-mapbox-gl/blob/master/docs/… but I don't know how to change visibility at runtime.
– Khurshid Ansari
Mar 7 at 5:35
docs.mapbox.com/help/troubleshooting/mapbox-gl-js-performance/…. Please check this. i think this might help @KhurshidAnsari
– Akshay Mulgavkar
Mar 7 at 5:59
This is mapbox gl js
– Khurshid Ansari
Mar 7 at 6:10
add a comment |
I can see that you are using a older depreciated version of mapbox-gl.
This package is deprecated please use this instead.
Installation
Dependencies
node
npm
React Native recommended version 0.50 or greater
Git
git clone git@github.com:mapbox/react-native-mapbox-gl.git
cd react-native-mapbox-gl
Yarn
yarn add @mapbox/react-native-mapbox-gl
Npm
npm install @mapbox/react-native-mapbox-gl --save
You're good to go!
I am using latest version.
– Khurshid Ansari
Mar 7 at 5:18
Do you know how to change layer visibility at run time?
– Khurshid Ansari
Mar 7 at 5:20
See github.com/agius/react-native-mapbox-gl/blob/master/docs/… but I don't know how to change visibility at runtime.
– Khurshid Ansari
Mar 7 at 5:35
docs.mapbox.com/help/troubleshooting/mapbox-gl-js-performance/…. Please check this. i think this might help @KhurshidAnsari
– Akshay Mulgavkar
Mar 7 at 5:59
This is mapbox gl js
– Khurshid Ansari
Mar 7 at 6:10
add a comment |
I can see that you are using a older depreciated version of mapbox-gl.
This package is deprecated please use this instead.
Installation
Dependencies
node
npm
React Native recommended version 0.50 or greater
Git
git clone git@github.com:mapbox/react-native-mapbox-gl.git
cd react-native-mapbox-gl
Yarn
yarn add @mapbox/react-native-mapbox-gl
Npm
npm install @mapbox/react-native-mapbox-gl --save
You're good to go!
I can see that you are using a older depreciated version of mapbox-gl.
This package is deprecated please use this instead.
Installation
Dependencies
node
npm
React Native recommended version 0.50 or greater
Git
git clone git@github.com:mapbox/react-native-mapbox-gl.git
cd react-native-mapbox-gl
Yarn
yarn add @mapbox/react-native-mapbox-gl
Npm
npm install @mapbox/react-native-mapbox-gl --save
You're good to go!
answered Mar 7 at 5:17
Akshay MulgavkarAkshay Mulgavkar
1386
1386
I am using latest version.
– Khurshid Ansari
Mar 7 at 5:18
Do you know how to change layer visibility at run time?
– Khurshid Ansari
Mar 7 at 5:20
See github.com/agius/react-native-mapbox-gl/blob/master/docs/… but I don't know how to change visibility at runtime.
– Khurshid Ansari
Mar 7 at 5:35
docs.mapbox.com/help/troubleshooting/mapbox-gl-js-performance/…. Please check this. i think this might help @KhurshidAnsari
– Akshay Mulgavkar
Mar 7 at 5:59
This is mapbox gl js
– Khurshid Ansari
Mar 7 at 6:10
add a comment |
I am using latest version.
– Khurshid Ansari
Mar 7 at 5:18
Do you know how to change layer visibility at run time?
– Khurshid Ansari
Mar 7 at 5:20
See github.com/agius/react-native-mapbox-gl/blob/master/docs/… but I don't know how to change visibility at runtime.
– Khurshid Ansari
Mar 7 at 5:35
docs.mapbox.com/help/troubleshooting/mapbox-gl-js-performance/…. Please check this. i think this might help @KhurshidAnsari
– Akshay Mulgavkar
Mar 7 at 5:59
This is mapbox gl js
– Khurshid Ansari
Mar 7 at 6:10
I am using latest version.
– Khurshid Ansari
Mar 7 at 5:18
I am using latest version.
– Khurshid Ansari
Mar 7 at 5:18
Do you know how to change layer visibility at run time?
– Khurshid Ansari
Mar 7 at 5:20
Do you know how to change layer visibility at run time?
– Khurshid Ansari
Mar 7 at 5:20
See github.com/agius/react-native-mapbox-gl/blob/master/docs/… but I don't know how to change visibility at runtime.
– Khurshid Ansari
Mar 7 at 5:35
See github.com/agius/react-native-mapbox-gl/blob/master/docs/… but I don't know how to change visibility at runtime.
– Khurshid Ansari
Mar 7 at 5:35
docs.mapbox.com/help/troubleshooting/mapbox-gl-js-performance/…. Please check this. i think this might help @KhurshidAnsari
– Akshay Mulgavkar
Mar 7 at 5:59
docs.mapbox.com/help/troubleshooting/mapbox-gl-js-performance/…. Please check this. i think this might help @KhurshidAnsari
– Akshay Mulgavkar
Mar 7 at 5:59
This is mapbox gl js
– Khurshid Ansari
Mar 7 at 6:10
This is mapbox gl js
– Khurshid Ansari
Mar 7 at 6:10
add a comment |
Finally I got solution :
constructor()
this.state =
lightMap: 'visible',
darkMap: 'none'
;
changeMap()
this.setState(darkMap:'visible')
<MapboxGL.MapView
styleURL="asset://mystyle.json"
logoEnabled=false
attributionEnabled=false
ref=(e) => this.oMap = e
zoomLevel=6
centerCoordinate=[54.0, 24.0]
style= flex: 1 >
<MapboxGL.RasterSource
id="idLightMap"
url="LAYERURL1"
tileSize=256>
<MapboxGL.RasterLayer
id="idLightMap"
sourceID="idLightMap"
style=visibility: this.state.lightMap>
</MapboxGL.RasterLayer>
</MapboxGL.RasterSource>
<MapboxGL.RasterSource
id="idDarkMap"
url="LAYERURL2"
tileSize=256>
<MapboxGL.RasterLayer
id="idDarkMap"
sourceID="idDarkMap"
style=visibility: this.state.darkMap>
</MapboxGL.RasterLayer>
</MapboxGL.RasterSource>
</MapboxGL.MapView>
I have added raster layer and programmatic toggling it.
add a comment |
Finally I got solution :
constructor()
this.state =
lightMap: 'visible',
darkMap: 'none'
;
changeMap()
this.setState(darkMap:'visible')
<MapboxGL.MapView
styleURL="asset://mystyle.json"
logoEnabled=false
attributionEnabled=false
ref=(e) => this.oMap = e
zoomLevel=6
centerCoordinate=[54.0, 24.0]
style= flex: 1 >
<MapboxGL.RasterSource
id="idLightMap"
url="LAYERURL1"
tileSize=256>
<MapboxGL.RasterLayer
id="idLightMap"
sourceID="idLightMap"
style=visibility: this.state.lightMap>
</MapboxGL.RasterLayer>
</MapboxGL.RasterSource>
<MapboxGL.RasterSource
id="idDarkMap"
url="LAYERURL2"
tileSize=256>
<MapboxGL.RasterLayer
id="idDarkMap"
sourceID="idDarkMap"
style=visibility: this.state.darkMap>
</MapboxGL.RasterLayer>
</MapboxGL.RasterSource>
</MapboxGL.MapView>
I have added raster layer and programmatic toggling it.
add a comment |
Finally I got solution :
constructor()
this.state =
lightMap: 'visible',
darkMap: 'none'
;
changeMap()
this.setState(darkMap:'visible')
<MapboxGL.MapView
styleURL="asset://mystyle.json"
logoEnabled=false
attributionEnabled=false
ref=(e) => this.oMap = e
zoomLevel=6
centerCoordinate=[54.0, 24.0]
style= flex: 1 >
<MapboxGL.RasterSource
id="idLightMap"
url="LAYERURL1"
tileSize=256>
<MapboxGL.RasterLayer
id="idLightMap"
sourceID="idLightMap"
style=visibility: this.state.lightMap>
</MapboxGL.RasterLayer>
</MapboxGL.RasterSource>
<MapboxGL.RasterSource
id="idDarkMap"
url="LAYERURL2"
tileSize=256>
<MapboxGL.RasterLayer
id="idDarkMap"
sourceID="idDarkMap"
style=visibility: this.state.darkMap>
</MapboxGL.RasterLayer>
</MapboxGL.RasterSource>
</MapboxGL.MapView>
I have added raster layer and programmatic toggling it.
Finally I got solution :
constructor()
this.state =
lightMap: 'visible',
darkMap: 'none'
;
changeMap()
this.setState(darkMap:'visible')
<MapboxGL.MapView
styleURL="asset://mystyle.json"
logoEnabled=false
attributionEnabled=false
ref=(e) => this.oMap = e
zoomLevel=6
centerCoordinate=[54.0, 24.0]
style= flex: 1 >
<MapboxGL.RasterSource
id="idLightMap"
url="LAYERURL1"
tileSize=256>
<MapboxGL.RasterLayer
id="idLightMap"
sourceID="idLightMap"
style=visibility: this.state.lightMap>
</MapboxGL.RasterLayer>
</MapboxGL.RasterSource>
<MapboxGL.RasterSource
id="idDarkMap"
url="LAYERURL2"
tileSize=256>
<MapboxGL.RasterLayer
id="idDarkMap"
sourceID="idDarkMap"
style=visibility: this.state.darkMap>
</MapboxGL.RasterLayer>
</MapboxGL.RasterSource>
</MapboxGL.MapView>
I have added raster layer and programmatic toggling it.
answered Mar 10 at 10:40
Khurshid AnsariKhurshid Ansari
672617
672617
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55036420%2fhow-to-show-hide-raster-layer-visibility-property-visible-none-at-run-time-in%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown