Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
Add Transit Layer (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbdemonte committed Jan 1, 2016
1 parent ca4696d commit 19c4418
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ Available options:
- streetviewpanorama
- styledmaptype
- trafficlayer
- transitlayer
- trigger


Expand Down
33 changes: 33 additions & 0 deletions assets/demo/trafficlayer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script>
<script type="text/javascript" src="../gmap3.js"></script>
<style>
.gmap3{
margin: 20px auto;
border: 1px dashed #C0C0C0;
width: 500px;
height: 250px;
}
</style>

<script type="text/javascript">
$(function(){
$("#test").gmap3(
{ map:{
options:{
center:[34.04924594193164, -118.24104309082031],
zoom: 13
}
}
},
"trafficlayer"
);
});
</script>
<body>
<div id="test" class="gmap3"></div>
</body>
</html>
33 changes: 33 additions & 0 deletions assets/demo/transitlayer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script>
<script type="text/javascript" src="../gmap3.js"></script>
<style>
.gmap3{
margin: 20px auto;
border: 1px dashed #C0C0C0;
width: 500px;
height: 250px;
}
</style>

<script type="text/javascript">
$(function(){
$("#test").gmap3(
{ map:{
options:{
center:[34.04924594193164, -118.24104309082031],
zoom: 13
}
}
},
"transitlayer"
);
});
</script>
<body>
<div id="test" class="gmap3"></div>
</body>
</html>
17 changes: 16 additions & 1 deletion dist/gmap3.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function initDefaults() {
},
classes: (function () {
var r = {};
$.each("Map Marker InfoWindow Circle Rectangle OverlayView StreetViewPanorama KmlLayer TrafficLayer BicyclingLayer GroundOverlay StyledMapType ImageMapType".split(" "), function (_, k) {
$.each("Map Marker InfoWindow Circle Rectangle OverlayView StreetViewPanorama KmlLayer TrafficLayer TransitLayer BicyclingLayer GroundOverlay StyledMapType ImageMapType".split(" "), function (_, k) {
r[k] = gm[k];
});
return r;
Expand Down Expand Up @@ -2140,6 +2140,21 @@ function Gmap3($this) {
manageEnd(args, obj);
};


/**
* add a transit layer
**/
self.transitlayer = function (args) {
newMap();
var obj = store.get("transitlayer");
if (!obj) {
obj = new defaults.classes.TransitLayer();
obj.setMap(map);
store.add(args, "transitlayer", obj);
}
manageEnd(args, obj);
};

/**
* add a bicycling layer
**/
Expand Down
2 changes: 1 addition & 1 deletion dist/gmap3.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion gulp-options.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var features = ["autofit", "bicyclinglayer", "circle", "clear", "cluster", "defaults", "destroy", "directionsrenderer",
"exec", "get", "getaddress", "getdistance", "getelevation", "getgeoloc", "getlatlng", "getmaxzoom", "getroute",
"groundoverlay", "imagemaptype", "infowindow", "kmllayer", "marker", "overlay", "panel", "polygon", "polyline", "rectangle",
"streetviewpanorama", "styledmaptype", "trafficlayer", "trigger"],
"streetviewpanorama", "styledmaptype", "trafficlayer", "transitlayer", "trigger"],

dependencies = {
cluster: ["overlay", "marker"],
Expand Down Expand Up @@ -55,6 +55,8 @@ var features = ["autofit", "bicyclinglayer", "circle", "clear", "cluster", "defa
selector: ["marker"],
streetviewpanorama: ["marker", "infowindow"],
tags: ["get", "marker", "clear"],
trafficlayer: ["trafficlayer"],
transitlayer: ["transitlayer"],
trigger: ["trigger"]
};

Expand Down
17 changes: 17 additions & 0 deletions src/gmap3.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,23 @@ function Gmap3($this) {
};
// {{/trafficlayer}}


// {{#transitlayer}}
/**
* add a transit layer
**/
self.transitlayer = function (args) {
newMap();
var obj = store.get("transitlayer");
if (!obj) {
obj = new defaults.classes.TransitLayer();
obj.setMap(map);
store.add(args, "transitlayer", obj);
}
manageEnd(args, obj);
};
// {{/transitlayer}}

// {{#bicyclinglayer}}
/**
* add a bicycling layer
Expand Down
2 changes: 1 addition & 1 deletion src/tools/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function initDefaults() {
},
classes: (function () {
var r = {};
$.each("Map Marker InfoWindow Circle Rectangle OverlayView StreetViewPanorama KmlLayer TrafficLayer BicyclingLayer GroundOverlay StyledMapType ImageMapType".split(" "), function (_, k) {
$.each("Map Marker InfoWindow Circle Rectangle OverlayView StreetViewPanorama KmlLayer TrafficLayer TransitLayer BicyclingLayer GroundOverlay StyledMapType ImageMapType".split(" "), function (_, k) {
r[k] = gm[k];
});
return r;
Expand Down

0 comments on commit 19c4418

Please sign in to comment.