Skip to content

Commit 7e15b9d

Browse files
author
Paul Bulai
committed
added map-type documentation
1 parent feedbfc commit 7e15b9d

File tree

5 files changed

+106
-0
lines changed

5 files changed

+106
-0
lines changed

app/scripts/controllers/api.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ angular.module('angularGoogleMapsApp')
88
'circle',
99
'layer',
1010
'map-control',
11+
'map-type',
1112
'marker',
1213
'marker-label',
1314
'markers',

app/views/directive/map-type.html

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<new-scope>
2+
<p>The <code>map-type</code> directive is used to add custom map types, as overlays or single layers.</p>
3+
4+
<h4>Usage</h4>
5+
6+
<div hljs language="html" include="'map-type-template'"></div>
7+
<h4>Parameters</h4>
8+
9+
<p>Required properties are in red.</p>
10+
<table class="table table-bordered table-striped">
11+
<thead>
12+
<tr>
13+
<th>Param</th>
14+
<th>Type</th>
15+
<th>Details</th>
16+
</tr>
17+
</thead>
18+
<tbody>
19+
<tr>
20+
<td>options</td>
21+
<td><span class="label label-danger">expression</span></td>
22+
<td>Map type options, including in particular <code>getTile</code> or <code>getTileUrl</code> methods.
23+
For complete list of options see <a
24+
href="https://developers.google.com/maps/documentation/javascript/maptypes#MapTypeInterface"
25+
target="_blank">Google Maps API documentation</a>.
26+
</td>
27+
</tr>
28+
<tr>
29+
<td>id</td>
30+
<td><span class="label label-info">string</span></td>
31+
<td>Map type id, to be used in the controler to display the maptype as a single layer.</td>
32+
</tr>
33+
<tr>
34+
<td>show</td>
35+
<td><span class="label label-info">expression</span></td>
36+
<td>Scope variable used to show the maptype as an overlay. Defaults to <code>true</code>, unless <code>id</code>
37+
has been defined
38+
</td>
39+
</tr>
40+
<tr>
41+
<td>refresh</td>
42+
<td><span class="label label-info">expression</span></td>
43+
<td>Variable or expression to watch, which will trigger a maptype refresh when changing.<br>
44+
Useful in the case where the <code>getTileUrl</code> is dynamically defined (for example using
45+
filters, options&hellip;), and you want to apply changes immediately.
46+
</td>
47+
</tr>
48+
</tbody>
49+
</table>
50+
51+
<h4>Examples</h4>
52+
<runnable-example example="'map-type'"></runnable-example>
53+
54+
<script type="text/ng-template" id="map-type-template">
55+
<ui-gmap-map-type
56+
options='{expression}'
57+
id="'{string}'"
58+
show='{expression}'
59+
refresh='{expression}'>
60+
</ui-gmap-map-type>
61+
</script>
62+
</new-scope>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div id="map_canvas" ng-controller="mainCtrl">
2+
<ui-gmap-google-map center="map.center" zoom="map.zoom">
3+
<ui-gmap-map-type options="squaresMapType" show="map.showOverlay"></ui-gmap-map-type>
4+
</ui-gmap-google-map>
5+
6+
<a class="btn btn-primary" ng-click="map.showOverlay = !map.showOverlay">Toggle overlay</a>
7+
</div>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "map-type",
3+
"files": ["index.html", "script.js", "../base/plnkr.html"]
4+
}

app/views/examples/map-type/script.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
angular
2+
.module('appMaps', ['uiGmapgoogle-maps'])
3+
.controller('mainCtrl', function($scope, $log) {
4+
// Define map type options
5+
$scope.squaresMapType = {
6+
getTile: function(coord, zoom, ownerDocument) {
7+
var div = ownerDocument.createElement('div');
8+
div.innerHTML = coord;
9+
div.style.width = this.tileSize.width + 'px';
10+
div.style.height = this.tileSize.height + 'px';
11+
div.style.fontSize = '10';
12+
div.style.borderStyle = 'solid';
13+
div.style.borderWidth = '1px';
14+
div.style.borderColor = '#AAAAAA';
15+
return div;
16+
},
17+
tileSize: new google.maps.Size(256, 256),
18+
name: 'Black Squares',
19+
maxZoom: 19,
20+
};
21+
22+
// Define map options
23+
$scope.map = {
24+
center: {
25+
latitude: 41.850033,
26+
longitude: -87.6500523
27+
},
28+
showOverlay: true,
29+
zoom: 10,
30+
};
31+
32+
});

0 commit comments

Comments
 (0)