-
Notifications
You must be signed in to change notification settings - Fork 3
/
README
92 lines (65 loc) · 2.79 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
Static Map
==========
This application provides a wrapper around Google static and dynamic map APIs
in a single interface. Given a list of coordinates, it builds the URL for
loading a map image from Google Static Maps. When clicked on the map image,
it loads the dynamic version of the same map, with the markers intact.
Dependencies
------------
StaticMap requires the jQuery library (any version after 1.2 will do) and
the jQuery Class plug-in (http://github.com/taylanpince/jquery-class/ ). A
Google Maps API key is also needed for it to run properly. All Google
JavaScript libraries are loaded dynamically so they don't need to be included
separately.
Installation
------------
From your media folder, create a symlink to the dist directory under the
static_map path:
ln -s ../lib/static_map/dist media/static_map
Make sure CSS and JS files are loaded on the templates where you will use
Static Map:
<style type="text/css">
@import "{{ MEDIA_URL }}static_map/css/static_map.css";
</style>
<script type="text/javascript" src="{{ MEDIA_URL }}static_map/js/
static_map{% if not DEBUG %}.min{% endif %}.js"></script>
Usage
-----
StaticMap class takes a selector and a dictionary of options:
- api_key: Google API key, required for both static and dynamic maps
- size: Dimensions of the map as an array
- center: Central coordinates of the map, as an array
- zoom: Zoom level of the map
- markers: An array of markers, each identified as a dictionary:
- coordinates: Coordinates of the marker, as an array
- title: A title for the marker, will only show up on a dynamic map
- description: A description for the marker
- media_url: A string that will be apended to media file paths
- maptype: A string describing the type of map. "roadmap" and "terrain"
currently work, nothing else has been tested.
After creating the container for the map, instantiate the class with options:
<div id="MapArea"></div>
<script type="text/javascript">
//<![CDATA[
new core.StaticMap("#MapArea", {
"media_url" : "{{ MEDIA_URL }}",
"api_key" : "{{ GOOGLE_MAPS_API_KEY }}",
"size" : [298, 298],
"center" : [41.9288, -87.6315],
"zoom" : 10,
"maptype" : "roadmap",
"markers" : [
{
"coordinates" : [41.9228, -87.6632],
"title" : "Title 1",
"description" : "Description 2"
},
{
"coordinates" : [42.9228, -88.6632],
"title" : "Title 2",
"description" : "Description 2"
}
]
});
//]]>
</script>