yourcelf / olwidget

Javascript library to replace textareas that contain WKT data with editable OpenLayers maps, and a django app using it for django forms and admin.
Other
91 stars 43 forks source link

Request: Custom XYZ tile servers #47

Open ddohler opened 13 years ago

ddohler commented 13 years ago

I'm using olwidget with a local tile provider (specifically http://mapspot.ge ), and in order to make it work, I had to add the following to olwidget.js in the "osm" dictionary:

omc: function() {
            return new OpenLayers.Layer.OSM("Open Maps Caucasus",
                    [
                            "http://a.tile.mapspot.ge/en/${z}/${x}/${y}.png"
                    ],
                    { numZoomLevels: 19,
                      attribution: "<a href=\"http://mapspot.ge\" target=\"_blank\">MapSpot</a> - Data by JumpStart International"});
    }
},

and then create a map of the type osm["omc"] in Django; there is no way, as far as I can tell, to do this purely from Django (aside from writing your own javascript template that generates the appropriate OpenLayers constructor, but then you're not really using olwidget anymore). I know that custom tile servers are relatively rare, but they do exist (I also found http://tile.openstreetmap.nl ), and so it would be very nice if there were an option to use a custom tile server (and attribution, of course) that follows the OpenStreetMap XYZ URL format.

dimkab commented 13 years ago

+1