Skip to content

Instantly share code, notes, and snippets.

View odoe's full-sized avatar
👽
It's full of stars

Rene Rubalcava odoe

👽
It's full of stars
View GitHub Profile
@odoe
odoe / Main.purs
Last active August 29, 2015 14:12
PureScript demo of LeafletJS
module Main where
import Debug.Trace
import Data.Foreign
import Data.Foreign.EasyFFI
import Control.Monad.Eff
foreign import data LMap :: *
foreign import data TileLayer :: *
foreign import data Mutable :: ! --need a mutable type to work with
@odoe
odoe / sample.purs
Created January 4, 2015 22:59
PureScript foreign import example
-- ["s", ""]
foreign import map'
"""
function  (s) { --"s"
  return function() { -- ""
    return L.map(s);
  }
}
""" :: forall eff. String -> Eff (m :: Mutable | eff) LMap
-- I think this is why the easy-ffi syntax is like this:
@odoe
odoe / layout.clj
Created January 12, 2015 15:28
Sample layout using hiccup with Leaflet lib
(ns mapviewer.views.layout
(:require [hiccup.page :refer [html5 include-css]]
[hiccup.page :refer [include-css include-js]]))
(defn common [& body]
(html5
[:head
[:title "Welcome to mapviewer"]
(include-css "/css/screen.css")
(include-css "http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css")]
@odoe
odoe / utils.cljs
Created January 12, 2015 15:37
Support lib for a ClojureScript proj
(ns site.utils)
(def L (this-as ct (aget ct "L")))
(def esri (.-esri L))
(def utilTemplate (.-template (.-Util L)))
(def ctr (array 45.528 -122.680))
@odoe
odoe / site.cljs
Created January 12, 2015 15:53
Sample ClojureScritp app with Leaflet
(ns site
(:require [site.utils :refer [L esri utilTemplate ctr zoom]]))
(defn parkStyle [_]
(clj->js { :color "#70ca49", :weight 2 }))
(def opts (clj->js { :style parkStyle }))
(def parkUrl "http://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis/rest/services/Portland_Parks/FeatureServer/0")
@odoe
odoe / leaflet-control.js
Last active August 29, 2015 14:13
Leaflet Control Template
L.Control.Sample = L.Control.extend({
options: {
// topright, topleft, bottomleft, bottomright
position: 'topright'
},
initialize: function (options) {
// constructor
},
onAdd: function (map) {
// happens after added to map
@odoe
odoe / LocatorContainer.js
Created February 9, 2015 16:52
Container for React widget
/** @jsx React.DOM */
define([
'react',
'dojo/query',
'dojo/dom',
'dojo/dom-construct',
'./components/Locator'
], function(
React,
query, dom, domConstruct,
@odoe
odoe / Locator.js
Created February 9, 2015 16:54
React component with EsriJS
/** @jsx React.DOM */
define([
'react'
], function(React) {
var LocatorWidget = React.createClass({
getInitialState: function() {
return {
x: 0,
y: 0
@odoe
odoe / CartoDBLayer.js
Created February 23, 2015 15:21
Using CartoDB data in the ArcGIS API for Javascript
define([
'dojo/_base/declare',
'dojo/request',
'esri/InfoTemplate',
'esri/layers/GraphicsLayer',
'esri/graphic',
'esri/geometry/webMercatorUtils',
'dojo/json'
@odoe
odoe / simpleedit.js
Created March 2, 2015 15:46
Simple edit tools for ArcGIS API for JavaScript
define([
'require',
'dojo/_base/declare',
'dojo/_base/lang',
'dojo/_base/array',
'dojo/Evented',
'dojo/on',
'dojo/dom',
'dijit/_WidgetBase',
'esri/toolbars/edit',