Created
February 14, 2014 16:14
-
-
Save workmaster2n/9003904 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Arc.module "Entities", (Entities, App, Backbone, Marionette, $, _) -> | |
| class Entities.Map extends Entities.Model | |
| initialize: ()-> | |
| this.on "change", ()-> | |
| alert "I changed myself" | |
| $.getJSON "locations/2/geometries.json", (data) -> | |
| this.zones = data | |
| #App.vent.trigger("map:show", this) | |
| #App.MapApp.Show.Controller.showMap(this) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Arc.module "MapApp.Show", (Show, App, Backbone, Marionette, $, _) -> | |
| class Show.Map extends Marionette.ItemView | |
| id: "map" | |
| template: "map/templates/map" | |
| initialize: ()-> | |
| this.model.on "change", ()-> | |
| alert "my map changed" | |
| render: ()-> | |
| this.$el.width($(App.mainRegion.el).width()*.9) | |
| this.$el.height($(App.mainRegion.el).width()*.618) | |
| zoneDefaultStyle = new OpenLayers.Style({ | |
| 'fillColor': '#EAEDC2', | |
| 'strokeColor': '#8A9676', | |
| 'fillOpacity': .9 | |
| }) | |
| zoneSelectStyle = new OpenLayers.Style({ | |
| 'fillColor': '#37FDFC', | |
| 'strokeColor': '#00CDCD', | |
| 'fillOpacity': .5 | |
| }) | |
| zoneStyleMap = new OpenLayers.StyleMap( | |
| 'default': zoneDefaultStyle | |
| 'select': zoneSelectStyle | |
| ) | |
| options = { div: this.el, units: "dd", numZoomLevels: 25, fractionalZoom: true, allOverlays: true } | |
| map = new OpenLayers.Map(options) | |
| zones = this.model.zones | |
| wktLayer = new OpenLayers.Layer.Vector("zones", styleMap: zoneStyleMap) | |
| map.addLayer(wktLayer) | |
| for zone in zones | |
| if zone.geometries.length == 0 | |
| continue | |
| for geometry in zone.geometries | |
| polygonFeature = new OpenLayers.Feature.Vector(OpenLayers.Geometry.fromWKT(geometry.geom), | |
| {state: null, id: zone.id, polyid: '#440700', rules_url: zone.rules_url, name: zone.name}) | |
| wktLayer.addFeatures(polygonFeature) | |
| #zoom to extent of all zones | |
| b = wktLayer.getDataExtent() | |
| b.top = b.top + 2 | |
| b.bottom = b.bottom - 2 | |
| b.right = b.right + 2 | |
| b.left = b.left - 2 | |
| map.zoomToExtent(b) | |
| this |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment