Created
April 3, 2014 21:28
-
-
Save aarontam/9963268 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enyo.kind({ | |
name: 'GoogleMap', | |
kind: 'Control', | |
published: { | |
zoom: 16, | |
center: null, | |
mapTypeId: 0, | |
useDefaultUI: true, | |
debugMode: false | |
}, | |
events: { | |
onMapCreated: '' | |
}, | |
components: [ | |
{name: 'map', classes: 'enyo-google-map-map'} | |
], | |
//* @protected | |
create: function() { | |
this.inherited(arguments); | |
this.center = { | |
lat: 37.787186, | |
lng: -122.401037 | |
}; | |
}, | |
rendered: function() { | |
this.inherited(arguments); | |
this.createMap(); | |
}, | |
createMap: function() { | |
this.mapTypeId = this.mapTypeId || google.maps.MapTypeId.ROADMAP; | |
if (this.map) { | |
this.destroyMap(); | |
} | |
if (this.$.map.hasNode()) { | |
this.map = new google.maps.Map(this.$.map.hasNode(), { | |
center: new google.maps.LatLng(this.center.lat, this.center.lng), | |
zoom: this.zoom, | |
disableDefaultUI: !this.useDefaultUI, | |
mapTypeId: this.mapTypeId, | |
modeDiagnostics: this.debugMode | |
}); | |
this.doMapCreated(); | |
} | |
}, | |
destroyMap: function() { | |
this.map = null; | |
}, | |
updateCenter: function() { | |
var latlng = new google.maps.LatLng(this.center.lat, this.center.lng); | |
this.map.panTo(latlng); | |
}, | |
setCenter: function(inLat, inLng) { | |
this.center.lat = inLat; | |
this.center.lng = inLng; | |
this.updateCenter(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment