ezd.6359:

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?

smiley.1438:

This forum’s software sucks. <.<
It sucks so hard that i’ve written my reply in markdown.

https://gist.github.com/codemasher/50d75a36d28558231a92

(yes, i’m desperate)

ezd.6359:

Thx! I will try to adapt my code.

It seems i need to make my own list of continents/floors/regions/maps.

One more question: is it possible to restrict leaflet from zooming out of “max bounds”? It is working in old version of leaflet by default
leaflet.js (0.5.1) http://jsfiddle.net/cliff/CRRGC/
Latest stable version is 0.7.3 – https://jsfiddle.net/CRRGC/947/ – you can zoom to max.

smiley.1438:

One more question: is it possible to restrict leaflet from zooming out of “max bounds”? It is working in old version of leaflet by default

I’m pretty sure that was the feature bug which caused the map to jump on the screen on low zoom levels when it was smaller than the element which contained it. This has been fixed in more recent versions.

Edit: here’s an example: http://gw2.chillerlan.net/examples/gw2-maps-leaflet.html

ezd.6359:

Bug? Hehe. I think it is a nice thing Much better than useless grey background. So, should i write my own code to reproduce this “bug” or leaflet has an option for it?