JavaScript React: FitBounts issue when passing array of lonlat - react-mapbox-gl

Am trying to use fitBounds to make all my markers visible with a proper zoom level.

getBounds(){
   return [[12.49637,41.90278],[12.319398,45.441906],[13.055054,47.809532],[16.373724,48.208244]]
}

<Map
   style="mapbox://styles/mapbox/streets-v9"
   containerStyle={{
     height: "100%",
     width: "100%"
   }}
   fitBounds={this.getBounds()}>
     <markers /> 
</Map>

and am getting this error

Error: Invalid LngLat object: (12.49637,41.90278, 12.319398,45.441906)
 at new LngLat (bundle.js:118874)
 at Function.LngLat.convert (bundle.js:118874)
 at LngLatBounds.setSouthWest (bundle.js:118876)
 at new LngLatBounds (bundle.js:118876)
 at Function.LngLatBounds.convert (bundle.js:118876)
 at e.i.fitBounds (bundle.js:119021)
 at ReactMapboxGl.ReactMapboxFactory.ReactMapboxGl.componentDidMount (bundle.js:124648)
 at commons.js:19945
 at measureLifeCyclePerf (commons.js:19755)
 at commons.js:19944

Am not getting whats wrong here. Please help me with this.

Here the react-component am using alex3165/react-mapbox-gl

Answer:1

This seems fairly simple but I can't get this to run. I basically want to check if 'div class = balances' contains the text 'EUR' and if it does, I want to do other checks. It works when I use an ...

This seems fairly simple but I can't get this to run. I basically want to check if 'div class = balances' contains the text 'EUR' and if it does, I want to do other checks. It works when I use an ...

  1. if statement protractor element

I'm trying to remove a specific object when a property matches my parameter (Here when the name of the wheel is "Michelin") but I can't make it work... How could I do it ? var car = { type: "...

I'm trying to remove a specific object when a property matches my parameter (Here when the name of the wheel is "Michelin") but I can't make it work... How could I do it ? var car = { type: "...

  1. remove nested object javascript
  2. lodash remove nested object
  3. mongodb remove nested object
  4. mongoose remove nested object
  5. remove nested json object
  6. remove nested property from object javascript
  7. nested object remove

I want to create a reusable component where the DOM structure can be different each time the component is rendered. Let's say I have this class Comp extends React.Component { constructor() { ...

I want to create a reusable component where the DOM structure can be different each time the component is rendered. Let's say I have this class Comp extends React.Component { constructor() { ...

  1. react render sub component
  2. react force render subcomponent

I want to upload an image to the server using Ajax, but there is a problem. Would somebody please help me what is wrong here. I could submit the image using submit form but not ajax. here is my code: ...

I want to upload an image to the server using Ajax, but there is a problem. Would somebody please help me what is wrong here. I could submit the image using submit form but not ajax. here is my code: ...

  1. upload image using javascript
  2. upload image using postman
  3. upload image using jquery ajax
  4. upload image using ajax without form
  5. upload image using retrofit android example
  6. upload image using selenium webdriver
  7. upload image using php
  8. upload image using retrofit android
  9. upload image using jquery
  10. upload image using volley library in android
  11. upload image using curl php
  12. upload image using html
  13. upload image using ajax in laravel
  14. upload image using ajax in php
  15. upload image using laravel
  16. upload image using web api c#
  17. upload image using codeigniter
  18. upload image using axios
  19. upload image using node js
  20. upload image using angular 8