Lost two days. Can’t understand what to do :/ Help?
1) How to determine right coords/bounds? I want to change focus of the map with java scripts outside of the map.
For example i load https://api.guildwars2.com/v2/continents/1/floors/1 it looks like right place to show Tyria.
I can use sectors coords to focus the map in right position.
var bounds=new L.LatLngBounds(
this.map.unproject([0,32768],max_zoom),
this.map.unproject([32768, 0],max_zoom)
);
this.map.setMaxBounds(bounds);
...
this.map.setView(pos);
this.map.panTo(this.map.unproject(pos,zoom)).setZoom(zoom);
…
If i try to use “clamp” (continent_rect of the map), i can’t focus to right position.
var bounds=new L.LatLngBounds(
this.map.unproject([continent_rect[0][0],continent_rect[0][1]],max_zoom),
this.map.unproject([continent_rect[1][0],continent_rect[1][1]],max_zoom)
).pad(0.2);
this.map.setMaxBounds(bounds);
...
this.map.setView(pos);
this.map.panTo(this.map.unproject(pos,zoom)).setZoom(zoom);
…
… sectors coords move the map to wrong place. I don’t understand it. How to translate maps api coords/map_rect/continent_rect to right form (for leaflet)?
2) How to show right map names? Or how to show maps from different regions?
a) Since API does not provide “label_coords” for map names i try to calculate right position using continent_rect. It works, but some regions have too many maps (and names), it makes “map name” unusable because they lie in same place. How to filter wrong names?
X=(info['continent_rect'][1][0]-info['continent_rect'][0][0])/2+info['continent_rect'][0][0],
Y=(info['continent_rect'][1][1]-info['continent_rect'][0][1])/2+info['continent_rect'][0][1]
For example i use “continent/1/floor/1”. Region=8 has many maps and it fail everything. All these names lie in same place (corresponding map).
https://api.guildwars2.com/v2/continents/1/floors/1/regions/8
It looks like it: http://i.gyazo.com/e25894fbd3bfd4e4828e15be544df413.png
3) How to show those maps from region 8? They have same parameters (continent/floor/rect) as normal maps.
How to filter dungeons or special events maps etc?
I need (only default floors):
- Tyria maps
- Main dungeons
- WvWvW
4) Is there any list/API that can map GW2 API info -> usuable info?
Like:
Tyria:{
regions{
maps: {
continent_id=1
floor_id=1
center=coords
default_zoom=X
label_coords=coords
...
}
}
}
Duangeons:{
maps: {
Ascalonian Catacoms
...
}
}
All items should be in one instance. At this moment API provides duplicate names. For example
https://api.guildwars2.com/v2/continents/1/floors/-2/regions/2/maps/33
https://api.guildwars2.com/v2/continents/1/floors/-2/regions/2/maps/36
Which is right? How to understand it automatically without having special lists of ids, continents, floors etc?
English is not my native language, sorry :<