{"action":"created","issue":{"url":"https://api.github.com/repos/OSMBuildings/OSMBuildings/issues/3","labels_url":"https://api.github.com/repos/OSMBuildings/OSMBuildings/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/OSMBuildings/OSMBuildings/issues/3/comments","events_url":"https://api.github.com/repos/OSMBuildings/OSMBuildings/issues/3/events","html_url":"https://github.com/OSMBuildings/OSMBuildings/issues/3","id":94006498,"number":3,"title":"Have the ability to load geoJSON straight from a variable as string","user":{"login":"hrishiballal","id":1588744,"avatar_url":"https://avatars.githubusercontent.com/u/1588744?v=3","gravatar_id":"","url":"https://api.github.com/users/hrishiballal","html_url":"https://github.com/hrishiballal","followers_url":"https://api.github.com/users/hrishiballal/followers","following_url":"https://api.github.com/users/hrishiballal/following{/other_user}","gists_url":"https://api.github.com/users/hrishiballal/gists{/gist_id}","starred_url":"https://api.github.com/users/hrishiballal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hrishiballal/subscriptions","organizations_url":"https://api.github.com/users/hrishiballal/orgs","repos_url":"https://api.github.com/users/hrishiballal/repos","events_url":"https://api.github.com/users/hrishiballal/events{/privacy}","received_events_url":"https://api.github.com/users/hrishiballal/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-09T10:01:01Z","updated_at":"2015-07-09T10:12:18Z","closed_at":null,"body":"Currently, addGeoJSON fires a request to read a external file. However, geojson features may be stored in the browser context as a string or JSON. The library should have the ability to pass this string to the addGeoJSON method to render as well. \r\n"},"comment":{"url":"https://api.github.com/repos/OSMBuildings/OSMBuildings/issues/comments/119898819","html_url":"https://github.com/OSMBuildings/OSMBuildings/issues/3#issuecomment-119898819","issue_url":"https://api.github.com/repos/OSMBuildings/OSMBuildings/issues/3","id":119898819,"user":{"login":"hrishiballal","id":1588744,"avatar_url":"https://avatars.githubusercontent.com/u/1588744?v=3","gravatar_id":"","url":"https://api.github.com/users/hrishiballal","html_url":"https://github.com/hrishiballal","followers_url":"https://api.github.com/users/hrishiballal/followers","following_url":"https://api.github.com/users/hrishiballal/following{/other_user}","gists_url":"https://api.github.com/users/hrishiballal/gists{/gist_id}","starred_url":"https://api.github.com/users/hrishiballal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hrishiballal/subscriptions","organizations_url":"https://api.github.com/users/hrishiballal/orgs","repos_url":"https://api.github.com/users/hrishiballal/repos","events_url":"https://api.github.com/users/hrishiballal/events{/privacy}","received_events_url":"https://api.github.com/users/hrishiballal/received_events","type":"User","site_admin":false},"created_at":"2015-07-09T10:12:18Z","updated_at":"2015-07-09T10:12:18Z","body":"Hi Jan, \r\nI tried it but it is creating the Request object to look for the file. When I code below is not working, basically if I put hte geojson in a file, it is putting it but not so when I pass a string. \r\n\r\n<!DOCTYPE html>\r\n<html>\r\n<head>\r\n  <title>OSM Buildings</title>\r\n  <meta charset=\"utf-8\">\r\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\">\r\n  <style>\r\n    html, body {\r\n      margin: 0;\r\n      padding: 0;\r\n      width: 100%;\r\n      height: 100%;\r\n    }\r\n\r\n    #map {\r\n      width: 100%;\r\n      height: 100%;\r\n    }\r\n\r\n    .control {\r\n      position: absolute;\r\n      left: 0;\r\n      z-index: 1000;\r\n    }\r\n\r\n    .control.tilt {\r\n      top: 0;\r\n    }\r\n\r\n    .control.rotation {\r\n      top: 45px;\r\n    }\r\n\r\n    .control.zoom {\r\n      top: 90px;\r\n    }\r\n\r\n    .control.zoom button{\r\n      font-weight: normal;\r\n    }\r\n\r\n    .control button {\r\n      width: 30px;\r\n      height: 30px;\r\n      margin: 15px 0 0 15px;\r\n      border: 1px solid #999999;\r\n      background: #ffffff;\r\n      opacity: 0.6;\r\n      border-radius: 5px;\r\n      box-shadow: 0 0 5px #666666;\r\n      font-weight: bold;\r\n      text-align: center;\r\n    }\r\n\r\n    .control button:hover {\r\n      opacity: 1;\r\n      cursor: pointer;\r\n    }\r\n  </style>\r\n  <script src=\"OSMBuildings.js\"></script>\r\n</head>\r\n\r\n<body>\r\n<div id=\"map\"></div>\r\n\r\n<div class=\"control tilt\">\r\n  <button class=\"dec\">&#8601;</button>\r\n  <button class=\"inc\">&#8599;</button>\r\n</div>\r\n\r\n<div class=\"control rotation\">\r\n  <button class=\"inc\">&#8630;</button>\r\n  <button class=\"dec\">&#8631;</button>\r\n</div>\r\n\r\n<div class=\"control zoom\">\r\n  <button class=\"dec\">-</button>\r\n  <button class=\"inc\">+</button>\r\n</div>\r\n\r\n<script>\r\n  function positionOnMap(obj) {\r\n    document.addEventListener('keydown', function(e) {\r\n      var transInc = e.altKey ? 0.0002 : 0.00002;\r\n      var rotaInc = e.altKey ? 0.1 : 0.01;\r\n      switch (e.which) {\r\n        case 37: obj.position.longitude -= transInc; break;\r\n        case 39: obj.position.longitude += transInc; break;\r\n        case 38: obj.position.latitude += transInc; break;\r\n        case 40: obj.position.latitude -= transInc; break;\r\n        case 187: obj.scale += rotaInc; break;\r\n        case 189: obj.scale -= rotaInc; break;\r\n        default: return;\r\n      }\r\n      console.log(JSON.stringify({\r\n        position:{\r\n          latitude:parseFloat(obj.position.latitude.toFixed(5)),\r\n          longitude:parseFloat(obj.position.longitude.toFixed(5))\r\n        },\r\n        scale:parseFloat(obj.scale.toFixed(2))\r\n      }));\r\n    });\r\n  }\r\n\r\n  //*************************************************************************\r\n\r\n  var map = new OSMBuildings('map', {\r\n    position: { latitude:52.52000, longitude:13.41000 },\r\n    baseDir: '.',\r\n    // zoom: 16,\r\n    // rotation: 0, // optional\r\n    // tilt: 0, // optional\r\n    // disabled: true, // disables user input - optional\r\n    minZoom: 14.5,\r\n    maxZoom: 22,\r\n    tileSource: 'http://{s}.tiles.mapbox.com/v3/osmbuildings.kbpalbpk/{z}/{x}/{y}.png',\r\n    dataSource: null, // null disables default OSM data,\r\n    showBackfaces: true, // render front and backsides of polygons. false increases performance, true might be needed for bad geometries\r\n    backgroundColor: '#bfb8b0',\r\n    attribution: '© <a href=\"http://osmbuildings.org/copyright/\">OpenStreetMap</a> contributors, Map tiles © <a href=\"http://mapbox.com\">MapBox</a>, 3D © <a href=\"http://osmbuildings.org\">OSM Buildings</a></div>'\r\n  });\r\n  var gj = {\r\n  \"type\": \"FeatureCollection\",\r\n  \"features\": [\r\n    {\r\n      \"type\": \"Feature\",\r\n      \"properties\": {\r\n      \"height\":20,\r\n        \"minHeight\":-100,\r\n        \"color\": \"rgb(255,200,0)\"\r\n        },\r\n      \"geometry\": {\r\n        \"type\": \"Polygon\",\r\n        \"coordinates\": [\r\n          [\r\n            [\r\n              13.409929275512695,\r\n              52.51850591655913\r\n            ],\r\n            [\r\n              13.41331958770752,\r\n              52.517422163556766\r\n            ],\r\n            [\r\n              13.412439823150635,\r\n              52.51627309503224\r\n            ],\r\n            [\r\n              13.409671783447266,\r\n              52.51543738995772\r\n            ],\r\n            [\r\n              13.407247066497803,\r\n              52.515646317716474\r\n            ],\r\n            [\r\n              13.409929275512695,\r\n              52.51850591655913\r\n            ]\r\n          ]\r\n        ]\r\n      }\r\n    },\r\n    {\r\n      \"type\": \"Feature\",\r\n      \"properties\": {\r\n      \"height\": 0\r\n      },\r\n      \"geometry\": {\r\n        \"type\": \"Polygon\",\r\n        \"coordinates\": [\r\n          [\r\n            [\r\n              13.404393196105957,\r\n              52.52036651448786\r\n            ],\r\n            [\r\n              13.404393196105957,\r\n              52.52178965550562\r\n            ],\r\n            [\r\n              13.405863046646118,\r\n              52.52178965550562\r\n            ],\r\n            [\r\n              13.405863046646118,\r\n              52.52036651448786\r\n            ],\r\n            [\r\n              13.404393196105957,\r\n              52.52036651448786\r\n            ]\r\n          ]\r\n        ]\r\n      }\r\n    }\r\n  ]\r\n};\r\n  map.addGeoJSON(gj);\r\n\r\n</script>\r\n</body>\r\n</html>\r\n"}}