Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map not fitting into the canvas #47

Open
Kavya-siix opened this issue Aug 18, 2020 · 5 comments
Open

map not fitting into the canvas #47

Kavya-siix opened this issue Aug 18, 2020 · 5 comments

Comments

@Kavya-siix
Copy link

Kavya-siix commented Aug 18, 2020

Hi,
I am beginner in the web server application . when i try to load the 2D map ino the web page the map not fitting how to solve this issue?
thanks
Screenshot from 2020-08-18 16-41-49

@zainmehdi
Copy link

Any solution to this ?

@TeerapongPoom
Copy link

From ros2djs tutorial http://wiki.ros.org/ros2djs/Tutorials/VisualizingAMap
I added this line
viewer.shift(-8.75,-5.25);
into this function

gridClient.on('change', function(){
  viewer.scaleToDimensions(gridClient.currentGrid.width, gridClient.currentGrid.height);
});

Those numbers (-8.75,-5.25) are my map's width and height in meter divided by 2 and it worked for me.
I'm not sure about why it have to be negative though.
Screenshot from 2021-12-20 16-43-38
Screenshot from 2021-12-20 16-43-14

@tsinflam2
Copy link

From ros2djs tutorial http://wiki.ros.org/ros2djs/Tutorials/VisualizingAMap I added this line viewer.shift(-8.75,-5.25); into this function

gridClient.on('change', function(){
  viewer.scaleToDimensions(gridClient.currentGrid.width, gridClient.currentGrid.height);
});

Those numbers (-8.75,-5.25) are my map's width and height in meter divided by 2 and it worked for me. I'm not sure about why it have to be negative though. Screenshot from 2021-12-20 16-43-38 Screenshot from 2021-12-20 16-43-14

Thanks. It's working.
May I know how do you know there is a shift() of viewers when there is no documentation?

@TeerapongPoom
Copy link

From ros2djs tutorial http://wiki.ros.org/ros2djs/Tutorials/VisualizingAMap I added this line viewer.shift(-8.75,-5.25); into this function

gridClient.on('change', function(){
  viewer.scaleToDimensions(gridClient.currentGrid.width, gridClient.currentGrid.height);
});

Those numbers (-8.75,-5.25) are my map's width and height in meter divided by 2 and it worked for me. I'm not sure about why it have to be negative though. Screenshot from 2021-12-20 16-43-38 Screenshot from 2021-12-20 16-43-14

Thanks. It's working.
May I know how do you know there is a shift() of viewers when there is no documentation?

I'm not quite sure how did I find it back then. I think I found it in the source code here at line 76.

@messageid
Copy link

Hi,
Just a little update on the issue, using this change callback the map will fitt on canvas without magic numbers:

gridClient.on('change', function(){
  viewer.scaleToDimensions(gridClient.currentGrid.width, gridClient.currentGrid.height);
  viewer.shift(gridClient.currentGrid.pose.position.x,gridClient.currentGrid.pose.position.y);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants