Mikhail Korobov committed 2cf5531

Basic map widget

Comments (0)

Files changed (2)

 * latitude
 * geocode_error - True if geocoder wasn't able to handle the address
+Admin address preview
+django-easy-maps provides basic widget that displays a map under the address
+field. It can be used in admin for map previews. Example usage::
+    from django import forms
+    from django.contrib import admin
+    from easy_maps.widgets import AddressWithMapWidget
+    from firms.models import Firm
+    class FirmAdmin(admin.ModelAdmin):
+        class form(forms.ModelForm):
+            class Meta:
+                widgets = {
+                    'address': AddressWithMapWidget({'class': 'vTextField'})
+                }
+, FirmAdmin)


+from django.forms import TextInput
+from django.template import Template, Context
+class AddressWithMapWidget(TextInput):
+    def render(self, name, value, attrs=None):
+        default_html = super(AddressWithMapWidget, self).render(name, value, attrs)
+        map_template = Template("{% load easy_maps_tags %}{% easy_map address 700 200 16 %}")
+        context = Context({'address': value})
+        return default_html + map_template.render(context)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.