Skip to content

Instantly share code, notes, and snippets.

@abruzzi
Created January 12, 2014 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abruzzi/8385795 to your computer and use it in GitHub Desktop.
Save abruzzi/8385795 to your computer and use it in GitHub Desktop.
openlayers with angularjs popup demo
var app = angular.module('OpenLayersApp', []);
app.controller('EventController',
['$scope', '$compile', '$timeout', function($scope, $compile, $timeout) {
var map = new OpenLayers.Map("map",{projection:"EPSG:3857"});
var osm = new OpenLayers.Layer.OSM();
var toMercator = OpenLayers.Projection.transforms['EPSG:4326']['EPSG:3857'];
var center = toMercator({x:-0.05,y:51.5});
map.addLayers([osm]);
map.setCenter(new OpenLayers.LonLat(center.x,center.y), 13);
$scope.data = {
text: "Sun Mansi",
time: new Date()
};
var template = "<div><span>{{data.time}}</span> / <span>{{data.text}}</span></div>";
$scope.showPopup = function() {
var content = $compile(template)($scope);
var lonlat = "-5694.06868525478, 6708925.0877411375";
$timeout(function() {
var popup = new OpenLayers.Popup.FramedCloud("popup",
OpenLayers.LonLat.fromString(lonlat),
null,
content.html(),
null,
true
);
map.addPopup(popup);
}, 0);
};
}]);
@abruzzi
Copy link
Author

abruzzi commented Mar 4, 2014

img.olTileImage {
    max-width: inherit;
}

using foundation with openlayers, need this line to fix the image squash issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment