Обновление

More
11 years 1 month ago #1345 by Dima
Replied by Dima on topic Обновление
Вот вторая
function getNormalizedCoord(coord, zoom)
    {
      var y = coord.y;
      var x = coord.x;
      
      var tileRange = 1 << zoom;
      
      if (y < 0 || y >= tileRange) { return null; }
      if (x < 0 || x >= tileRange)
      {
        x = (x % tileRange + tileRange) % tileRange;
      }
      
      return { x: x, y: y };
    }

Don't forget support my developments: post review in JED , donate , help with translation ;)

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #1346 by Dima
Replied by Dima on topic Обновление
Вставить вторую функцию в первую - получите функцию получения тайлов.

Только для типа карты надо поставить соответствующий тип проекции

Don't forget support my developments: post review in JED , donate , help with translation ;)

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #1348 by Dima
Replied by Dima on topic Обновление
Итак, все очень просто.

Я на тестовом сайте воспроизвел оба варианта (не буду трогать типы карт неделю, можете сравнивать). Созможно, на этом сделаю урок в доках

Итак,

Вот гугловский компонент
development.zhuk.cc/index.php/howtofind2
Там есть тип карты "Locia"

Вот яндекс компонент
development.zhuk.cc/index.php/howtofind
Там тоже есть тип карты "Locia"

В яндексе нет ограничения на масштаб, надо почитать, может можно закинуть в настройки

Различие небольшое, для того, чтобы не сильно усложнять - закинул функцию в функцию, хотя в гугловском можно сделать красивее

Don't forget support my developments: post review in JED , donate , help with translation ;)

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #1349 by Dima
Replied by Dima on topic Обновление
В яндексе:
- проекция сферичю меркатор
- Вот тело функции получения тайлов
function(coord, zoom)
          {

function getNormalizedCoord(coord, zoom)
    {
      var y = coord[1];
      var x = coord[0];
      
      var tileRange = 1 << zoom;
      
      if (y < 0 || y >= tileRange) { return null; }
      if (x < 0 || x >= tileRange)
      {
        x = (x % tileRange + tileRange) % tileRange;
      }
      
      return { x: x, y: y };
    }

          var normalizedCoord = getNormalizedCoord(coord, zoom);
          if (!normalizedCoord) { return null; }
          
          if ( zoom == 7 && normalizedCoord.x >= 79 && normalizedCoord.x <= 82 && normalizedCoord.y >= 39 && normalizedCoord.y <= 44 )
          {
            return "http://camapka2.narod.ru/gmaps/lotsia/Z" + zoom + "/" + normalizedCoord.y + "/" + normalizedCoord.x + ".png"; // replace that with a "real" URL
          }
          if ( zoom == 8 && normalizedCoord.x >= 159 && normalizedCoord.x <= 164 && normalizedCoord.y >= 79 && normalizedCoord.y <= 88 )
          {
            return "http://camapka2.narod.ru/gmaps/lotsia/Z" + zoom + "/" + normalizedCoord.y + "/" + normalizedCoord.x + ".png"; // replace that with a "real" URL
          }
          else if ( zoom == 9 && normalizedCoord.x >= 319 && normalizedCoord.x <= 329 && normalizedCoord.y >= 159 && normalizedCoord.y <= 176 )
          {
            return "http://camapka2.narod.ru/gmaps/lotsia/Z" + zoom + "/" + normalizedCoord.y + "/" + normalizedCoord.x + ".png"; // replace that with a "real" URL
          }
          else if ( zoom == 10 && normalizedCoord.x >= 639 && normalizedCoord.x <= 658 && normalizedCoord.y >= 318 && normalizedCoord.y <= 352 )
          {
            return "http://camapka2.narod.ru/gmaps/lotsia/Z" + zoom + "/" + normalizedCoord.y + "/" + normalizedCoord.x + ".png"; // replace that with a "real" URL
          }
          else if ( zoom == 11 && normalizedCoord.x >= 1278 && normalizedCoord.x <= 1317 && normalizedCoord.y >= 636 && normalizedCoord.y <= 704 )
          {
            return "http://camapka2.narod.ru/gmaps/lotsia/Z" + zoom + "/" + normalizedCoord.y + "/" + normalizedCoord.x + ".png"; // replace that with a "real" URL
          }
          else if ( zoom == 12 && normalizedCoord.x >= 2556 && normalizedCoord.x <= 2634 && normalizedCoord.y >= 1272 && normalizedCoord.y <= 1409 )
          {
            return "http://camapka2.narod.ru/gmaps/lotsia/Z" + zoom + "/" + normalizedCoord.y + "/" + normalizedCoord.x + ".png"; // replace that with a "real" URL
          }
          else if ( zoom == 13 && normalizedCoord.x >= 5112 && normalizedCoord.x <= 5269 && normalizedCoord.y >= 2544 && normalizedCoord.y <= 2819 )
          {
            return "http://camapka2.narod.ru/gmaps/lotsia/Z" + zoom + "/" + normalizedCoord.y + "/" + normalizedCoord.x + ".png"; // replace that with a "real" URL
          }
          if ( zoom == 14 && normalizedCoord.x >= 10224 && normalizedCoord.x <= 10538 && normalizedCoord.y >= 5088 && normalizedCoord.y <= 5639 )
          {
            return "http://camapka2.narod.ru/gmaps/lotsia/Z" + zoom + "/" + normalizedCoord.y + "/" + normalizedCoord.x + ".png"; // replace that with a "real" URL
          }
          return null;
        }

Don't forget support my developments: post review in JED , donate , help with translation ;)

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #1350 by Dima
Replied by Dima on topic Обновление
Вот для моего гугловского компонента
function(coord, zoom)
          {

function getNormalizedCoord(coord, zoom)
    {
      var y = coord.y;
      var x = coord.x;
      
      var tileRange = 1 << zoom;
      
      if (y < 0 || y >= tileRange) { return null; }
      if (x < 0 || x >= tileRange)
      {
        x = (x % tileRange + tileRange) % tileRange;
      }
      
      return { x: x, y: y };
    }
          var normalizedCoord = getNormalizedCoord(coord, zoom);
          if (!normalizedCoord) { return null; }
          
          if ( zoom == 7 && normalizedCoord.x >= 79 && normalizedCoord.x <= 82 && normalizedCoord.y >= 39 && normalizedCoord.y <= 44 )
          {
            return "http://camapka2.narod.ru/gmaps/lotsia/Z" + zoom + "/" + normalizedCoord.y + "/" + normalizedCoord.x + ".png"; // replace that with a "real" URL
          }
          if ( zoom == 8 && normalizedCoord.x >= 159 && normalizedCoord.x <= 164 && normalizedCoord.y >= 79 && normalizedCoord.y <= 88 )
          {
            return "http://camapka2.narod.ru/gmaps/lotsia/Z" + zoom + "/" + normalizedCoord.y + "/" + normalizedCoord.x + ".png"; // replace that with a "real" URL
          }
          else if ( zoom == 9 && normalizedCoord.x >= 319 && normalizedCoord.x <= 329 && normalizedCoord.y >= 159 && normalizedCoord.y <= 176 )
          {
            return "http://camapka2.narod.ru/gmaps/lotsia/Z" + zoom + "/" + normalizedCoord.y + "/" + normalizedCoord.x + ".png"; // replace that with a "real" URL
          }
          else if ( zoom == 10 && normalizedCoord.x >= 639 && normalizedCoord.x <= 658 && normalizedCoord.y >= 318 && normalizedCoord.y <= 352 )
          {
            return "http://camapka2.narod.ru/gmaps/lotsia/Z" + zoom + "/" + normalizedCoord.y + "/" + normalizedCoord.x + ".png"; // replace that with a "real" URL
          }
          else if ( zoom == 11 && normalizedCoord.x >= 1278 && normalizedCoord.x <= 1317 && normalizedCoord.y >= 636 && normalizedCoord.y <= 704 )
          {
            return "http://camapka2.narod.ru/gmaps/lotsia/Z" + zoom + "/" + normalizedCoord.y + "/" + normalizedCoord.x + ".png"; // replace that with a "real" URL
          }
          else if ( zoom == 12 && normalizedCoord.x >= 2556 && normalizedCoord.x <= 2634 && normalizedCoord.y >= 1272 && normalizedCoord.y <= 1409 )
          {
            return "http://camapka2.narod.ru/gmaps/lotsia/Z" + zoom + "/" + normalizedCoord.y + "/" + normalizedCoord.x + ".png"; // replace that with a "real" URL
          }
          else if ( zoom == 13 && normalizedCoord.x >= 5112 && normalizedCoord.x <= 5269 && normalizedCoord.y >= 2544 && normalizedCoord.y <= 2819 )
          {
            return "http://camapka2.narod.ru/gmaps/lotsia/Z" + zoom + "/" + normalizedCoord.y + "/" + normalizedCoord.x + ".png"; // replace that with a "real" URL
          }
          if ( zoom == 14 && normalizedCoord.x >= 10224 && normalizedCoord.x <= 10538 && normalizedCoord.y >= 5088 && normalizedCoord.y <= 5639 )
          {
            return "http://camapka2.narod.ru/gmaps/lotsia/Z" + zoom + "/" + normalizedCoord.y + "/" + normalizedCoord.x + ".png"; // replace that with a "real" URL
          }
          return null;
        }

Don't forget support my developments: post review in JED , donate , help with translation ;)

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #1351 by Dima
Replied by Dima on topic Обновление
Различие только в одном
function getNormalizedCoord(coord, zoom)
    {
      var y = coord.y;
      var x = coord.x;

function getNormalizedCoord(coord, zoom)
    {
      var y = coord[1];
      var x = coord[0];

Т.е. как в конечном варианте функции работают с переданным параметром координат coord

Don't forget support my developments: post review in JED , donate , help with translation ;)

Please Log in or Create an account to join the conversation.

Time to create page: 0.083 seconds

Donate


Go to top