Pergunta

I am doing a little project on Geo Locations. I need to highlight certain cities on an a map that is in equirectangular projection. I have got the LON LAT values for those cities, I need to find a way to translate those values to actual x,y coordinates on screen that will work with any size of map (with equirectangular projection). I have found a code but that does it for Mercator projection. Any Clue ?Thanks

Foi útil?

Solução

That is quite simpler than doing Mercator projection, try this function:

public function getXY(lat:Number, lng:Number):Point
{
  var screenX:Number = ((lng + 180) * (mapWidth  / 360));
  var screenY:Number = (((lat * -1) + 90) * (mapHeight/ 180));

  return new Point(screenX,screenY);
}

mapWidth and mapHeight should be the width and height of your Map's Image that you are using. This function will return you the translated coordinates from LAT LON to X, Y of your screen with respect to your map size.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top