|
| 1 | +module Main where |
| 2 | + |
| 3 | +import Prelude (bind, negate) |
| 4 | +import Control.Monad.Eff (Eff) |
| 5 | + |
| 6 | +import Leaflet.Map (createMap) |
| 7 | +import Leaflet.Types |
| 8 | + ( URL |
| 9 | + , LatLng |
| 10 | + , LatLngBounds |
| 11 | + , MapOptions |
| 12 | + , TileLayer |
| 13 | + , TileLayerOptions) |
| 14 | +import Leaflet.LatLng (latLng) |
| 15 | +import Leaflet.LatLngBounds (latLngBounds) |
| 16 | +import Leaflet.TileLayer (tileLayer) |
| 17 | +import Leaflet.Layer (addTo) |
| 18 | + |
| 19 | +defCenter :: LatLng |
| 20 | +defCenter = latLng (-0.09349) (-78.43276) |
| 21 | + |
| 22 | +minBound :: LatLng |
| 23 | +minBound = latLng (-100.0) (-100.0) |
| 24 | + |
| 25 | +maxBound :: LatLng |
| 26 | +maxBound = latLng 100000.0 10000000.0 |
| 27 | + |
| 28 | +defMaxBounds :: LatLngBounds |
| 29 | +defMaxBounds = latLngBounds minBound maxBound |
| 30 | + |
| 31 | +defMapOps :: MapOptions |
| 32 | +defMapOps = |
| 33 | + { |
| 34 | + attributionControl : true, |
| 35 | + center : defCenter, |
| 36 | + layers : [], |
| 37 | + maxBounds : defMaxBounds, |
| 38 | + zoom : 16 |
| 39 | + } |
| 40 | + |
| 41 | +osmURL :: URL |
| 42 | +osmURL = "http://{s}.tile.osm.org/{z}/{x}/{y}.png" |
| 43 | + |
| 44 | +osmSubdomains :: Array String |
| 45 | +osmSubdomains = [ "a", "b", "c" ] |
| 46 | + |
| 47 | +defTileLayerOptions :: TileLayerOptions (attribution :: String) |
| 48 | +defTileLayerOptions = |
| 49 | + { subdomains : osmSubdomains |
| 50 | + , attribution: "© <a href=\"http://osm.org/copyright\">OpenStreetMap</a> contributors" |
| 51 | + } |
| 52 | + |
| 53 | +main :: forall e. Eff e TileLayer |
| 54 | +main = do |
| 55 | + defTileLayer <- tileLayer osmURL defTileLayerOptions |
| 56 | + myMap <- createMap "mapid" defMapOps |
| 57 | + addTo defTileLayer myMap |
| 58 | + |
0 commit comments