Method: MapProject::MapProject#offset_on_viewport

Defined in:
lib/map_project/map_project.rb

#offset_on_viewport(p_lat, p_long) ⇒ Object

project the map coords to viewport, return a point’s offsets on viewport (0,0) (0, x)

------------
|          |
| viewport |
|          |
------------

(y, 0) (x, y) Return: the projected offset of the point Usage example: css sprite



52
53
54
55
56
57
58
59
# File 'lib/map_project/map_project.rb', line 52

def offset_on_viewport(p_lat, p_long)
  input_pixel_coords = world_to_pixel(lat_lng_to_world(p_lat, p_long))

  [
    (pixel_bounds_based_on_center[:sw][1] - input_pixel_coords[1]).abs,
    (pixel_bounds_based_on_center[:ne][0] - input_pixel_coords[0]).abs
  ]
end