Package: django-markers
django-markersA dynamic map marker generator using template images and arbitrary text.WhySometimes you need to use a lot of markers on a map, many of which are similar,
but slightly different, using text labels, or even different colours or
opacities.  This will do that for you.Theoretically, you could also use it to caption memes, but I think there's
other stuff out there for that sort of thing.HowYou can reference the markers in three ways: using a django template tag, via
URL parameters, or in Python, by using theMarkerclass.  The preferred
method is the template tag, and I don't recommend using direct URL requests,
since it requires a hit to your application server every time.Using a Template TagThis will generate a media URL pointing to a newly-created marker based on atemplate.png, with the text42, positioned3pixels right, and3pixels
down from the upper left corner of the template, with an opacity of50%, a
hue-shift of105, and using the hex colour#333333for the text.  All the
arguments, save for the first, are optional:{%loadmarkers%}{%marker'path/to/template.png'text='42'text_x=3text_y=3opacity=0.5hue=105text_colour='333333'%}Typically, you'll use this in your template to assign marker paths to some
javascript variables:``django<script>
  var marker1 = "{% marker 'path/to/template.png' text='1' %}";
  var marker2 = "{% marker 'path/to/template.png' text='3' hue=105 %}";
</script>``After you have the URLs in your Javascript, you can do whatever you like with
them, they're just URLs to existing static files.Using Direct LinksThe same arguments passed to the template tag can be passed in a URL:https://localhost:8000/markers/path/to/template.png?text=42&opacity=0.5&text_x=3&text_y=3&text_colour=333333&hue=105Using the Python ModelMarker generation is as easy as instantiating a model:``python
from markers.models import Markermymarker = Marker(
"path/to/template.png",
text="42",
opacity=0.5,
text_x=3,
text_y=3,
text_colour="333333",
hue=105
)
``The TemplatesThe template path you pass todjango-markers, must be part of one of your
apps, and referenced as such.  So for example, if you have a template living inmapping/static/mapping/img/markers/mytemplate.png, the argument you're
looking for is:mapping/img/markers/mytemplate.png.If you're calling the URL directly, then you'll append this path to the URL
like so:https://localhost:8000/markers/mapping/img/markers/mytemplate.png?hue=105&opacity=0.8A Note on Text PositioningBy default, we try to centre text along the x/y axis, so if that's your
intention, don't specify either.  Specifying anxvalue without ayone
will assumeyto be centred and vice versa.A Note on Template ImagesYou can use whatever image you like for your templates, but since the
hue-shifting starts at red (0), and progresses through the spectrum to red
again at 360, you'd do well to use a redish image as your template.
Otherwise, requests that don't specify ahuewill look out of step with
ones that havehueset to1.InstallationYou can install it from pypi usingpip:$pipinstalldjango-markersOr you can install it from GitHub:$pipinstallgit+https://github.com/danielquinn/django-markers.git#egg=django-markersThen in yoursettings.py:INSTALLED_APPS=(..."markers",)And if you want to make use of the direct URL requests, you'll need to add this
to yoururls.py:url(r"^some/arbitrary/path/",include("markers.urls")),So for example, you would have something like this in yoururls.py:url(r"^mapping/markers/",include("markers.urls")),RequirementsWe're doing image processing here, soPILis required.  You should probably
usePillowthough, since that's what this was developed against.
Additionally,numpyis required to handle the hue-shifting.  Both will
install automatically if you follow the installation instructions above.In addition to these Python dependencies, Django 1.6+ is required if you
intend to make use of the on-the-fly generation via calling a specific URL.LicensingThe whole project is licensed under the GPL-3, but the default font used is
licensed under Apache 2.0.