{"id":497,"date":"2011-09-04T08:06:28","date_gmt":"2011-09-04T13:06:28","guid":{"rendered":"http:\/\/crschmidt.net\/blog\/?p=497"},"modified":"2011-09-04T08:06:28","modified_gmt":"2011-09-04T13:06:28","slug":"demo-leafletopenlayers-translator","status":"publish","type":"post","link":"https:\/\/crschmidt.net\/blog\/archives\/497\/demo-leafletopenlayers-translator\/","title":{"rendered":"Demo: Leaflet\/OpenLayers Translator"},"content":{"rendered":"<p><font style=\"position: absolute;overflow: hidden;height: 0;width: 0\"><a href=\"http:\/\/ikoni.eu\/ikoni\">&#1080;&#1082;&#1086;&#1085;&#1080;<\/a><\/font>For a long time, I&#8217;ve seen complaints that the OpenLayers API is &#8216;too complicated&#8217; &#8212; that there are too many options, that it&#8217;s too difficult to configure, etc. I&#8217;ve said for a long time that although OpenLayers offers a lot of power, it&#8217;s also possible to make things simpler with a relatively thin layer on top of OpenLayers &#8212; that the power doesn&#8217;t necessary have to compete with simplicity, but that maintaining a simple wrapper at the OpenLayers level is probably not ideal, for a lot of reasons.  <\/p>\n<p>I&#8217;m obviously not a good target for making a simpler API &#8212; I don&#8217;t consider OpenLayers difficult to use, so it&#8217;s really hard for me to be the one to implement an &#8216;easier&#8217; to use API! Thankfully, only 3.5 years after I started saying someone should write a simpler API, there appears to be a significant competitor to OpenLayers which is being praised for its ease of use: <a href=\"http:\/\/leaflet.cloudmade.com\/\">Leaflet<\/a>, from Cloudmade.<\/p>\n<p>So, after watching people continually praise the Leaflet API, I thought I&#8217;d see what it took to make OpenLayers as easy to use as Leaflet. I started with the <a href=\"http:\/\/leaflet.cloudmade.com\/examples\/quick-start-example.html\">Quick Start<\/a> example, and worked my way down the features of the page until I got to the end.<\/p>\n<p>The result is the <a href=\"http:\/\/crschmidt.github.com\/ol-leaflet-wrapper\/quick-start.html\">ol-leaflet-wrapper quick-start<\/a> &#8212; a substantially similar page, which looks the essentially the same as the Leaflet Quick Start guide (minus popups). Total code to implement: 99 lines.<\/p>\n<p>Now, I&#8217;m not saying this is a full-fledged wrapper: in fact, anyone with half a brain would be able to observe that this particular example is missing one big feature, in the form of popups. (In fact, I think this kind of demonstration is one very easy way to make it clear where the OpenLayers *library* is deficient: things that are hard to wrap between one library and another are a clear target for API refactoring and cleanup.) Any deeper look would show that I&#8217;ve only minimally wrapped Leaflet, and that a more complete wrapper would still be a significant investment.<\/p>\n<p>However, I do think that it&#8217;s possible to make the kinds of changes that people desire most from OpenLayers *without* completely reimplementing the library &#8212; and even without a refactoring of the (admittedly bulky) core library; instead, approaching a new API as something built on top of the existing is a way to rapidly prototype a new approach, and integration or improvements can move into the core library as needed.<\/p>\n<p>And if people who like OpenLayers really want a simpler API like Leaflet &#8212; well, I&#8217;m happy to help develop the Leaflet API wrapper into something more real, to help direct what a suitably friendly API for working with OpenLayers might actually look like.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#1080;&#1082;&#1086;&#1085;&#1080;For a long time, I&#8217;ve seen complaints that the OpenLayers API is &#8216;too complicated&#8217; &#8212; that there are too many options, that it&#8217;s too difficult to configure, etc. I&#8217;ve said for a long time that although OpenLayers offers a lot of power, it&#8217;s also possible to make things simpler with a relatively thin layer on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-497","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/posts\/497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/comments?post=497"}],"version-history":[{"count":0,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/posts\/497\/revisions"}],"wp:attachment":[{"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/media?parent=497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/categories?post=497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/crschmidt.net\/blog\/wp-json\/wp\/v2\/tags?post=497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}