5 <title>inset map example</title>
6 <meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">
7 <meta name="description" content="An example of inset map">
8 <meta name="author" content="Ryan Westphal">
9 <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/themes/blitzer/jquery-ui.css" />
10 <link rel="stylesheet" type="text/css" href="css/style.css" />
11 <style type="text/css">
23 border: solid 2px #444;
41 <a href="../" class="docLink">< docs</a>
42 <a href="http://jsfiddle.net/ryanttb/aH7kG/embedded/" class="fiddleLink"><img src="img/jsfiddle.png" alt="" /> jsFiddle ></a>
47 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
48 <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js"></script>
49 <script src="../jquery.geo-test.min.js"></script>
53 var map = $( "#map" ).geomap( {
54 center: [ -71.0595678, 42.3604823 ],
56 bboxchange: function( e, geo ) {
57 // whenever the bbox changes, update the inset map's shape
58 insetmap.geomap( "empty" );
59 insetmap.geomap( "append", bboxToPolygon( geo.bbox ) );
63 // create a smaller map
64 // stop interaction (static mode) and add the default service but
65 // without an attr property, it's on the main map
66 var insetmap = $( "#insetmap" ).geomap( {
67 center: [ -71.0595678, 42.3604823 ],
72 src: "http://tile.openstreetmap.org/{{:zoom}}/{{:tile.column}}/{{:tile.row}}.png"
76 // append a shape to the inset map to show the big map's bbox
77 insetmap.geomap( "append", bboxToPolygon( map.geomap( "option", "bbox" ) ) );
79 function bboxToPolygon( bbox ) {
80 // a quick function to convert a bbox into a true GeoJSON Polygon
84 [ bbox[ 0 ], bbox[ 1 ] ],
85 [ bbox[ 0 ], bbox[ 3 ] ],
86 [ bbox[ 2 ], bbox[ 3 ] ],
87 [ bbox[ 2 ], bbox[ 1 ] ],
88 [ bbox[ 0 ], bbox[ 1 ] ]
96 var _gaq = [['_setAccount', 'UA-26084853-1'], ['_trackPageview']];
98 var g = d.createElement(t), s = d.getElementsByTagName(t)[0]; g.async = 1;
99 g.src = ('https:' == location.protocol ? '//ssl' : '//www') + '.google-analytics.com/ga.js';
100 s.parentNode.insertBefore(g, s);
101 } (document, 'script'));