tentone / geo-three

Tile based geographic world map visualization library for threejs
https://tentone.github.io/geo-three/docs/
MIT License
700 stars 112 forks source link

How about to set map center #22

Open CrazyBoyLanZao opened 3 years ago

CrazyBoyLanZao commented 3 years ago

Hello, developer. First of all, thank you for developing such a user-friendly plugin. However, I have met some problems in specific use, and I hope you can answer them. I want to set the center position of the map, but I don't know how to operate it. When I read the development document, I found that the description in this part is not clear. I hope you can tell me how to set it.

tentone commented 3 years ago

Hello

You should be able tochange the center of the map by moving the MapView object around.

var map = new MapView(MapView.PLANAR, provider);
map.position.set(1,2,3);
scene.add(map);
CrazyBoyLanZao commented 3 years ago

I'm sorry ,maybe I didn't make it clear what I was trying to say. my idea is that I think this is some latitude,for example latitude 132, 30 longitude is the center of the map, but I didn't find that function.

CrazyBoyLanZao commented 3 years ago

Hello The default display of global map, but I just want to see the map of the Pacific Ocean, what should I do, looking forward to your reply。Thank you。

markbaumgarten commented 2 years ago

My guess is that your question might be: "How to make my scene rotate around a specific coordinate?" ...???

I am using geothree + openstreetmap and I'm moving my camera target to the coordinate instead of moving around the map.

In order to convert a WGS84 coordinate to a camera target vector that works in geothree you do this:

let longitude = 11.234;
let latitude = 55.1234
let coords = GEOTHREE.UnitsUtils.datumsToSpherical(latitude, longitude);

and to make your camera look/orbit around this point:

let camera_target = new THREE.Vector3(coords.x, y, -coords.y);
yourcamera.target = camera_target;
yourcamera.update()