-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathviewModel.js
More file actions
71 lines (55 loc) · 2.33 KB
/
viewModel.js
File metadata and controls
71 lines (55 loc) · 2.33 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
/**
Copyright (c) 2015, 2017, Oracle and/or its affiliates.
The Universal Permissive License (UPL), Version 1.0
api url and key = https://maps.googleapis.com/maps/api/js?key=AIzaSyA07vX9UwwikBu3pOhvXgpXJiWCBF9XpVI
*/
define(
['ojs/ojcore', 'knockout', 'jquery','gmaps'], function (oj, ko, $) {
'use strict';
function ExampleComponentModel(context) {
var self = this;
self.composite = context.element;
//Example observable
self.long = ko.observable();
self.lat = ko.observable();
self.width = ko.observable("400px");
self.height = ko.observable("400px");
self.composite.drawMap = function(){
console.log("long == "+ self.long())
console.log("lat == "+ self.lat())
var map;
var mapProp = {
center: new google.maps.LatLng(self.lat(), self.long()),
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
var marker = new google.maps.Marker({
position: new google.maps.LatLng(self.lat(), self.long()),
map: map
});
}
context.props.then(function (propertyMap) {
//Store a reference to the properties for any later use
self.properties = propertyMap;
if(self.properties.longitude && self.properties.latitude){
self.long(self.properties.longitude);
self.lat(self.properties.latitude);
self.width(self.properties.width);
self.height(self.properties.height);
}
//Parse your component properties here
});
};
//Lifecycle methods - uncomment and implement if necessary
//ExampleComponentModel.prototype.activated = function(context){
//};
ExampleComponentModel.prototype.attached = function(context){
};
ExampleComponentModel.prototype.bindingsApplied = function(context){
context.element.drawMap();
};
//ExampleComponentModel.prototype.detached = function(context){
//};
return ExampleComponentModel;
});