Hello Everyone ,
Here is simplest solution for creating numbered markers for google map,
You can use any platform for this solution , here i am using django, python.
Create a view that takes integer as a parameter .
Here is simplest solution for creating numbered markers for google map,
You can use any platform for this solution , here i am using django, python.
Create a view that takes integer as a parameter .
from django.http import HttpResponse
import PIL
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
def map_imagepin(request,num):
font = ImageFont.truetype("arial.ttf", 11)
text = str(num)
if len(text)==1:
text_pos = (16,13)
elif len(text) ==2:
text_pos = (13,13)
elif len(text)==3:
text_pos = (11,13)
tcolor = (255,255,255)
img = Image.open(r"c:\icon-pin.png")
draw = ImageDraw.Draw(img)
draw.text(text_pos, text, fill=tcolor,font=font)
font = ImageFont.truetype("arial.ttf", 11)
text = str(num)
if len(text)==1:
text_pos = (16,13)
elif len(text) ==2:
text_pos = (13,13)
elif len(text)==3:
text_pos = (11,13)
tcolor = (255,255,255)
img = Image.open(r"c:\icon-pin.png")
draw = ImageDraw.Draw(img)
draw.text(text_pos, text, fill=tcolor,font=font)
response = HttpResponse(mimetype="image/png")
img.save(response, "PNG")
return response
img.save(response, "PNG")
return response
Here is urls.py
urlpatterns = patterns('',
url(r'^/image/(\d+)/$', map_imagepin),
)
url(r'^/image/(\d+)/$', map_imagepin),
)
thaks nishant, it is really helpful...
ReplyDeletenice work
ReplyDeleteAwesome Solution, Simple answer to complex problem
ReplyDelete