Skip to content

Commit 1b1b337

Browse files
committed
Add customization options for marker color and icon Closes #1
1 parent f6e653d commit 1b1b337

12 files changed

+509
-153
lines changed

dev.py

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import argparse
2+
import re
3+
import os
4+
import sys
5+
6+
def update_package_version(version):
7+
with open('./pymaps/__version__.py', 'w') as f:
8+
f.write('__version__ = "{}"'.format(str(version)))
9+
10+
11+
if __name__ == '__main__':
12+
PYTHON = 'python'
13+
14+
parser = argparse.ArgumentParser()
15+
parser.add_argument("--version", help="number of the new package version")
16+
parser.add_argument("--gitpush", help="message for commit and push to Github")
17+
args = parser.parse_args()
18+
print(args)
19+
20+
if args.version:
21+
msg = '-' * 80 + '\nUPDATING PACKAGE VERSION TO {}\n' + '-' * 80
22+
print(msg.format(args.version))
23+
version_pattern = '[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}'
24+
version_is_valid = re.match(version_pattern, args.version) is not None
25+
if version_is_valid:
26+
update_package_version(args.version)
27+
print('Sucess!')
28+
else:
29+
raise ValueError('Invalid Version {}'.format(args.version))
30+
31+
THIS_DIR = os.getcwd()
32+
tests = 'setup.py test'
33+
docs = 'docs.py'
34+
install = 'setup.py install'
35+
36+
print('-' * 80 + '\nRUNNING TESTS\n' + '-' * 80)
37+
r = os.system(' '.join([PYTHON, tests]))
38+
if r != 0:
39+
raise SystemError('Error while testing.')
40+
41+
42+
print('-' * 80 + '\nBUILDING DOCS\n' + '-' * 80)
43+
os.chdir('./docs')
44+
r= os.system(' '.join([PYTHON, docs]))
45+
if r != 0:
46+
raise SystemError('Error while building docs.')
47+
os.chdir(THIS_DIR)
48+
49+
50+
print('-' * 80 + '\nINSTALLING PACKAGE\n' + '-' * 80)
51+
r= os.system(' '.join([PYTHON, install]))
52+
if r != 0:
53+
raise SystemError('Error while installing the package.')
54+
55+
if args.gitpush:
56+
print('-' * 80 + '\nPUSHING TO REPOSITORY\n' + '-' * 80)
57+
print('Git add')
58+
os.system('git add .')
59+
print('Git commit')
60+
os.system('git commit -m "{}"'.format(args.gitpush))
61+
print('Git push')
62+
os.system('git push')

docs/map-styles.ipynb

+13-13
Large diffs are not rendered by default.

docs/markers.ipynb

+203-50
Large diffs are not rendered by default.

docs/templates/tpl-map-styles.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@
448448
"name": "python",
449449
"nbconvert_exporter": "python",
450450
"pygments_lexer": "ipython3",
451-
"version": "3.6.3"
451+
"version": "3.6.2"
452452
}
453453
},
454454
"nbformat": 4,

docs/templates/tpl-markers.ipynb

+158-47
Original file line numberDiff line numberDiff line change
@@ -32,66 +32,56 @@
3232
"metadata": {},
3333
"source": [
3434
"<h1 class=\"title1\">Table of Contents</h1>\n",
35-
"* [Create a map with a marker](#marker1) "
35+
"* [Create a map with a marker](#marker1)\n",
36+
"* [Marker animation](#marker2)\n",
37+
"* [Custom icons](#marker3)\n",
38+
"* [Custom colors](#marker4)\n",
39+
"* [Custom icon from URL](#marker5) \n",
40+
"* [Creating a MarkerCluster](#marker6) "
3641
]
3742
},
3843
{
3944
"cell_type": "code",
40-
"execution_count": 1,
45+
"execution_count": null,
4146
"metadata": {
4247
"hideCode": false,
4348
"hidePrompt": false
4449
},
4550
"outputs": [],
4651
"source": [
4752
"import os\n",
48-
"\n",
49-
"import pandas as pd\n",
50-
"from pymaps import Map\n",
51-
"from pymaps.marker import Marker, MarkerCluster"
53+
"import random\n",
54+
"from IPython.display import HTML, display\n",
55+
"import pandas as pd"
5256
]
5357
},
5458
{
55-
"cell_type": "code",
56-
"execution_count": 2,
57-
"metadata": {
58-
"hideCode": false,
59-
"hidePrompt": false
60-
},
61-
"outputs": [],
59+
"cell_type": "markdown",
60+
"metadata": {},
6261
"source": [
63-
"API_KEY = os.environ['MAPS_API_KEY']"
62+
"<a id=\"marker1\"></a>\n",
63+
"<h1 class=\"title1\">Create a Map with a Marker</h1>"
6464
]
6565
},
6666
{
67-
"cell_type": "markdown",
67+
"cell_type": "code",
68+
"execution_count": null,
6869
"metadata": {},
70+
"outputs": [],
6971
"source": [
70-
"<a id=\"marker1\"></a>\n",
71-
"<h1 class=\"title1\">Create a Map with a Marker</h1>"
72+
"API_KEY = os.environ['MAPS_API_KEY']\n",
73+
"\n",
74+
"from pymaps import Map\n",
75+
"from pymaps.marker import Marker, MarkerCluster"
7276
]
7377
},
7478
{
7579
"cell_type": "code",
76-
"execution_count": 11,
80+
"execution_count": null,
7781
"metadata": {
7882
"scrolled": false
7983
},
80-
"outputs": [
81-
{
82-
"data": {
83-
"text/html": [
84-
"<iframe src=\"data:text/html;charset=utf-8;base64,PCFET0NUWVBFIGh0bWw+CjxodG1sPgogIDxoZWFkPgogICAgPHRpdGxlPlB5TWFwczwvdGl0bGU+CiAgICA8bWV0YSBuYW1lPSJ2aWV3cG9ydCIgY29udGVudD0iaW5pdGlhbC1zY2FsZT0xLjAiPgogICAgPG1ldGEgY2hhcnNldD0idXRmLTgiPgogICAgPHN0eWxlPgogICAgICAgICNtYXAgewogICAgICAgICAgICBoZWlnaHQ6IDUwMHB4OwogICAgICAgIH0KICAgICAgICBodG1sLCBib2R5IHsKICAgICAgICAgICAgaGVpZ2h0OiAxMDAlOwogICAgICAgICAgICBtYXJnaW46IDA7CiAgICAgICAgICAgIHBhZGRpbmc6IDA7CiAgICAgICAgfQogICAgPC9zdHlsZT4KICA8L2hlYWQ+CiAgPGJvZHk+CiAgICAKICAgIDxkaXYgaWQ9Im1hcCI+CiAgICAgIDwhLS0gTWFwIHdpbGwgYmUgcGxhY2VkIGhlcmUgLS0+CiAgICA8L2Rpdj4KICAgIDxzY3JpcHQ+CiAgICAgICAgZnVuY3Rpb24gaW5pdE1hcCgpIHsKICAgICAgICAgICAgdmFyIG1hcCA9IG5ldyBnb29nbGUubWFwcy5NYXAoZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoJ21hcCcpLCB7CiAgICAgICAgICAgICAgICB6b29tOiAxMywKICAgICAgICAgICAgICAgIGNlbnRlcjoge2xhdDogLTMuODU3NiwgbG5nOiAtMzIuNDI5N30sCiAgICAgICAgICAgICAgICBtYXBUeXBlSWQ6ICdyb2FkbWFwJywKICAgICAgICAgICAgICAgIHN0cmVldFZpZXdDb250cm9sOiAxLAogICAgICAgICAgICAgICAgem9vbUNvbnRyb2w6IDEsCiAgICAgICAgICAgICAgICBkaXNhYmxlRGVmYXVsdFVJOiAwLAogICAgICAgICAgICAgICAgCiAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgCiAgICAgICAgICAgICAgIC8vIG1hcCBtYXJrZXJzCiAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgdmFyIG1hcmtlcj1uZXcgZ29vZ2xlLm1hcHMuTWFya2VyKHtwb3NpdGlvbjp7bGF0Oi0zLjg1NzYsbG5nOi0zMi40Mjk3fSxkcmFnZ2FibGU6ZmFsc2UsbWFwOm1hcCx0aXRsZToiRmVybmFuZG8gZGUgTm9yb25oYSIsbGFiZWw6IiIsYW5pbWF0aW9uOm51bGwsaWNvbjpudWxsLG9wYWNpdHk6MSxvcHRpbWl6ZWQ6dHJ1ZX0pOwogICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAKCiAgICAgICAgICAgICAgIC8vIGZpdEJvdW5kcyBtZXRob2QKICAgICAgICAgICAgICAgCgogICAgICAgICAgICAgICAvLyBNYXJrZXJDbHVzdGVyCiAgICAgICAgICAgICAgIAoKICAgICAgICAgICAgCiAgICAgICAgfTsKCiAgICAgIC8vIEF0dGFjaGVzIGFuIGluZm8gd2luZG93IHRvIGEgbWFya2VyIHdpdGggdGhlIHByb3ZpZGVkIG1lc3NhZ2UKICAgICAgZnVuY3Rpb24gYXR0YWNoSW5mb1dpbmRvdyhtYXJrZXIsIG1lc3NhZ2UpIHsKICAgICAgICB2YXIgaW5mb3dpbmRvdyA9IG5ldyBnb29nbGUubWFwcy5JbmZvV2luZG93KHsKICAgICAgICAgIGNvbnRlbnQ6IG1lc3NhZ2UKICAgICAgICB9KTsKCiAgICAgICAgbWFya2VyLmFkZExpc3RlbmVyKCdjbGljaycsIGZ1bmN0aW9uKCkgewogICAgICAgICAgaW5mb3dpbmRvdy5vcGVuKG1hcmtlci5nZXQoJ21hcCcpLCBtYXJrZXIpOwogICAgICAgIH0pOwogICAgICB9OwogICAgPC9zY3JpcHQ+CgogICAgCiAgICA8c2NyaXB0IGFzeW5jIGRlZmVyCiAgICAgc3JjPSJodHRwczovL21hcHMuZ29vZ2xlYXBpcy5jb20vbWFwcy9hcGkvanM/a2V5PUFJemFTeUItWHNfTzJhaTZ6c0FVcmg5dGtrSFBTYkNTbTc3cHdrNCZjYWxsYmFjaz1pbml0TWFwIj4KICAgIDwvc2NyaXB0PgogIDwvYm9keT4KPC9odG1sPg==\" style=\"height:500px;width:100%;border:none !important\"></iframe>"
85-
],
86-
"text/plain": [
87-
"<pymaps.pymaps.Map at 0x7fdf8c1daa20>"
88-
]
89-
},
90-
"execution_count": 11,
91-
"metadata": {},
92-
"output_type": "execute_result"
93-
}
94-
],
84+
"outputs": [],
9585
"source": [
9686
"fernando_de_noronha = (-3.8576, -32.4297)\n",
9787
"m = Map(api_key=API_KEY, zoom=13)\n",
@@ -100,6 +90,13 @@
10090
"m"
10191
]
10292
},
93+
{
94+
"cell_type": "markdown",
95+
"metadata": {},
96+
"source": [
97+
"* Lets add more markers..."
98+
]
99+
},
103100
{
104101
"cell_type": "code",
105102
"execution_count": null,
@@ -136,6 +133,14 @@
136133
"map"
137134
]
138135
},
136+
{
137+
"cell_type": "markdown",
138+
"metadata": {},
139+
"source": [
140+
"<a id=\"marker2\"></a>\n",
141+
"## Marker animation"
142+
]
143+
},
139144
{
140145
"cell_type": "code",
141146
"execution_count": null,
@@ -149,6 +154,124 @@
149154
"map"
150155
]
151156
},
157+
{
158+
"cell_type": "markdown",
159+
"metadata": {},
160+
"source": [
161+
"<a id=\"marker3\"></a>\n",
162+
"## Built-in custom icons"
163+
]
164+
},
165+
{
166+
"cell_type": "code",
167+
"execution_count": null,
168+
"metadata": {},
169+
"outputs": [],
170+
"source": [
171+
"from pymaps.icon import *\n",
172+
"from pymaps.utils import random_latlng"
173+
]
174+
},
175+
{
176+
"cell_type": "markdown",
177+
"metadata": {},
178+
"source": [
179+
"There are **8 customs** icons and **19 color sets** that you can use to customize your markers"
180+
]
181+
},
182+
{
183+
"cell_type": "markdown",
184+
"metadata": {},
185+
"source": [
186+
"### Custom Icons"
187+
]
188+
},
189+
{
190+
"cell_type": "code",
191+
"execution_count": null,
192+
"metadata": {},
193+
"outputs": [],
194+
"source": [
195+
"m = Map(api_key=API_KEY)\n",
196+
"\n",
197+
"lat = 0\n",
198+
"lng = -80\n",
199+
"\n",
200+
"for n, shape in enumerate(SHAPES):\n",
201+
" color = list(COLORS.keys())[n] \n",
202+
" icon = Icon(shape, color=color, size=2)\n",
203+
" Marker([lat, lng], icon=icon, title=shape).add_to(m) \n",
204+
" lng += 20 \n",
205+
"m"
206+
]
207+
},
208+
{
209+
"cell_type": "markdown",
210+
"metadata": {},
211+
"source": [
212+
"<a id=\"marker4\"></a>\n",
213+
"## Built-in custom colors"
214+
]
215+
},
216+
{
217+
"cell_type": "code",
218+
"execution_count": null,
219+
"metadata": {},
220+
"outputs": [],
221+
"source": [
222+
"m = Map(api_key=API_KEY, style='grayscale')\n",
223+
"\n",
224+
"lat = -30\n",
225+
"lng = 0\n",
226+
"\n",
227+
"for n, color in enumerate(COLORS.keys()):\n",
228+
" if n > 0 and n % 5 == 0:\n",
229+
" lat += 20\n",
230+
" lng -= 100\n",
231+
" icon = Icon('dot', color=color, size=2)\n",
232+
" Marker([lat, lng], icon=icon, title=color).add_to(m) \n",
233+
" lng += 20 \n",
234+
"m"
235+
]
236+
},
237+
{
238+
"cell_type": "markdown",
239+
"metadata": {},
240+
"source": [
241+
"### Customize everything !"
242+
]
243+
},
244+
{
245+
"cell_type": "code",
246+
"execution_count": null,
247+
"metadata": {},
248+
"outputs": [],
249+
"source": [
250+
"m = Map(api_key=API_KEY, zoom=1, style='silver')\n",
251+
"for shape in SHAPES:\n",
252+
" size = random.randint(1, 3)\n",
253+
" color=random.choice([c for c in COLORS])\n",
254+
" icon = Icon(shape, color=color, size=size)\n",
255+
" coordinates = random_latlng()\n",
256+
" Marker(coordinates, icon=icon, title=shape + ' - ' + color).add_to(m)\n",
257+
"m"
258+
]
259+
},
260+
{
261+
"cell_type": "markdown",
262+
"metadata": {},
263+
"source": [
264+
"<a id=\"marker5\"></a>\n",
265+
"## Custom icon from URL"
266+
]
267+
},
268+
{
269+
"cell_type": "markdown",
270+
"metadata": {},
271+
"source": [
272+
"* Markers's icons also can be customized from any image URL"
273+
]
274+
},
152275
{
153276
"cell_type": "code",
154277
"execution_count": null,
@@ -174,23 +297,11 @@
174297
"map"
175298
]
176299
},
177-
{
178-
"cell_type": "code",
179-
"execution_count": null,
180-
"metadata": {
181-
"scrolled": false
182-
},
183-
"outputs": [],
184-
"source": [
185-
"map.children['marker'][-1].remove_animation()\n",
186-
"map.title = 'Eurotrip 2018'\n",
187-
"map"
188-
]
189-
},
190300
{
191301
"cell_type": "markdown",
192302
"metadata": {},
193303
"source": [
304+
"<a id=\"marker6\"></a>\n",
194305
"# MarkerCluster"
195306
]
196307
},
@@ -239,7 +350,7 @@
239350
"name": "python",
240351
"nbconvert_exporter": "python",
241352
"pygments_lexer": "ipython3",
242-
"version": "3.6.3"
353+
"version": "3.6.2"
243354
}
244355
},
245356
"nbformat": 4,

pymaps/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
from .pymaps import *
22
from . import marker
3-
4-
__version__ = '0.0.22'

pymaps/__version__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "0.1.0"

0 commit comments

Comments
 (0)