Indicate support, take DOM elements as input. Fixes #55.

This commit is contained in:
Tom MacWright
2012-11-02 14:14:47 -04:00
parent a2005aaaee
commit 4c90bf44d5
3 changed files with 27 additions and 4 deletions
+3 -2
View File
@@ -57,12 +57,13 @@
<script type="text/javascript" src="js/iD/Graph.js"></script>
<script>
var m = d3.select('#map'),
map = iD.Map('#map').setZoom(18).setCentre({
var map = iD.Map(document.getElementById('map')).setZoom(18).setCenter({
lat: 40.7965621,
lon: -74.4773184
});
var m = d3.select('#map');
iD.Hash().map(map);
window.onresize = function() {
+14
View File
@@ -1 +1,15 @@
if (typeof iD === 'undefined') var iD = {};
iD.supported = function() {
if (navigator.appName !== 'Microsoft Internet Explorer') {
return true;
} else {
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\\.0-9]{0,})");
if (re.exec(ua) !== null) {
rv = parseFloat( RegExp.$1 );
}
if (rv && rv < 9) return false;
else return true;
}
};
+10 -2
View File
@@ -1,4 +1,12 @@
iD.Map = function(parentSelector) {
iD.Map = function(elem) {
if (!iD.supported()) {
elem.innerHTML = 'This editor is supported in Firefox, Chrome, Safari, Opera, ' +
'and Internet Explorer 9 and above. Please upgrade your browser ' +
'or use Potlatch 2 to edit the map.';
elem.style.cssText = 'text-align:center;font-style:italic;';
return;
}
var map = {},
width, height,
@@ -7,7 +15,7 @@ iD.Map = function(parentSelector) {
graph = new iD.Graph(),
connection = new iD.Connection(graph);
inspector = iD.Inspector(graph),
parent = d3.selectAll(parentSelector),
parent = d3.select(elem),
selection = [],
projection = d3.geo.mercator()
.scale(512).translate([512, 512]),