yandex地图热点v2的tiles和js生成器
yandex-hotspots的Python项目详细描述
Yandex热点
python库为Yandex Maps Hotspots版本2生成tiles和js。 注意,热点js api没有很好的文档记录。自作自受。 适用于Python2.6-2.7。
这是Paul Koltyshev的一个应用程序分支,名为django-hotspots。 yandex热点是为了支持新版本的热点api和 主要是django免费包。
这个库只支持最简单的热点:点。
用法
子类HotspotsManager,并至少定义这些方法:
from PIL import Image from hotspots import HotspotsManager class MyHotspotsManager(HotspotsManager): img_big = Image.open('static/images/big_marker.png') img_small = Image.open('static/images/small_marker.png') def get_base_path(self): """ Where to save tiles""" return 'static/hotspots' def get_img(self, obj, scale): """ Hotspot image object""" return self.img_big if scale > 12 else self.img_small def get_lng(self, obj): """ Latitude of your object""" return obj.coordinates[0] def get_lat(self, obj): """ Longitude """ return obj.coordinates[1]
运行热点生成器:
# Obtain data for hotspots (some locations with data) data_iterable = [{'coordinates': (37.925288, 55.720903), 'title': 'My House'}, <...>] # Generate hotspots for zoom levels raging form 10 to 17 MyHotspotsManager().generate_tiles(data_iterable, scale=(10, 17))
最后把创建的热点和some clientside放在一起。
气球内容和提示
分别使用gett_descr(self,obj)和get_name(self,obj)。