public
Description: A Javascript library to create and embedded map to find the latitude and longitude of a point, using the ModestMaps Javascript API.
Homepage:
Clone URL: git://github.com/straup/js-iamheremap.git
js-iamheremap / README
100644 159 lines (98 sloc) 4.222 kb
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
I Am Here Map is a Javascript library to create and embedded map to find the
latitude and longitude of a point, using the ModestMaps Javascript API.
 
It also supports geocoding, reverse-geocoding and automagic client positioning
using a variety of geolocation providers as well as the ability to display shape
contours for locations that have been reverse-geocoded.
 
It is heavily indebted to Simon Willison's original www.getlatlon.com website.
 
# EXAMPLE
 
 <html>
<head>
         <title>I Am Here Map</title>
<script type="text/javascript" src="iamheremap.js"></script>
 
                <script>
 $(document).ready(function(){
var args = {
'modestmaps_provider' : 'CloudMade',
'flickr_apikey' : 'YER_FLICKR_APIKEY',
'cloudmade_apikey' : 'YER_CLOUDMADE_APIKEY',
'cloudmade_style' : 999,
'find_my_location' : false,
'enable_logging' : true,
};
 
window.map = new info.aaronland.iamhere.Map('iamheremap', args);
 });
</script>
</head>
        <body style="margin:0;">
         <div id="iamheremap"></div>
</body>
 </html>
 
# CONSTRUCTOR ARGUMENTS
 
* modestmaps_provider (required)
 
  It's not really, since there's only one tile provider (CloudMade) as of this
  writing but some day there will be more so you might as well get used to being
  specific about it.
 
* cloudmade_apikey (required)
 
  A valid CloudMade API key.
 
  Again, not really required except for the part where it is today.
 
  You can register for a CloudMade API at http://developer.cloudmade.com
 
* cloudmade_style
 
  A valid CloudMade API style identifier. Use '999' for the spooky.
 
  Required if your 'modestmaps_provider' is CloudMade (which it is).
 
* flickr_apikey
 
  A valid Flickr API key.
 
  Required for things like reverse geocoding and displaying location contours.
 
  You can register for a Flickr API key at http://www.flickr.com/services/api/keys/apply/
 
* find_my_location
 
  Attempt to do automatic client geolocation on startup.
 
* enable_logging
 
  Write events and errors to console.log
 
* map_height
 
Default is 400.
 
* map_width
 
Default is the width of the browser window.
 
# GEOCODING
 
Geocoding addresses is performed using either the Google Maps geocoding (v3) API
or the Flickr API, assuming the requisite libraries have been loaded and API
keys defined.
 
The order of precedence for geocoding is:
 
    * Google Maps API
 
    * Flickr API
 
# REVERSE GEOCODING
 
Reverse geocoding of points is performed using the Flickr API, assuming you've
included a valid Flickr API key.
 
# POSITIONING
 
Positioning (or geolocating) of the current user is attempted using a variety of
providers assuming the requisite libraries have been loaded and/or valid API
keys have been defined.
 
The order of precedence for positioning is:
 
    * Loki/Skyhook API
 
      Loki is first on the assumption that if you've passed a Loki API key then
      it's probably what you want to use; this may not hold true if you're using
      a browser/device with a built-in GPS unit but one step at a time.
 
    * Geode API (Firefox, only)
 
    * Google Gears Geolocation API
 
    * Google ClientLocation API (IP lookups)
 
The actual mechanics of the positioning logic are handled by the js-geolocation
library.
 
# KNOWN-KNOWNS
 
* This has only been tested in Firefox and Safari.
 
* The use (and size) of JQuery is probably overkill. All things being equal it
  will probably be replaced with plain-vanilla native DOM calls in time.
 
* The size and position of map (and the crosshairs) are fixed and don't update
  correctly when the window is resized.
 
* If a shapefile is rendered too close to, or overlaps, the zoom controls
  sometimes the zoom controls don't work.
 
* I haven't figured out packing/minifying for this yet. It's probably just a
  missing cluebat but so far when I try I end up with weird JS errors.
 
* This uses a slightly abused version of the ModestMaps 'mapcontrols-raphael.js'
  library because I haven't gotten around to writing a proper patch yet.
 
# BUGS?
 
Probably. Please to be gentle.
 
# SEE ALSO
 
* http://www.modestmaps.com/
 
* http://developer.cloudmade.com/
 
* http://raphaeljs.com/
 
* http://www.getlatlon.com/
 
* http://github.com/straup/js-flickr-api/
 
* http://github.com/straup/js-geolocation/