Development - mike-denton/GBC-Navigation-Application GitHub Wiki
npm install -g @angular/cli
Other versions with Angular provided issues with building and running during development.
To prevent this, copy and paste the following into your package.json
:
"@angular-devkit/architect": "~0.801.2"
"@angular-devkit/build-angular": "^0.801.2"
npm install -g ionic
npm install -g native-run
npm install -g cordova
ionic cordova run android
ionic cordova run ios
Requirements to work with Android Devices:
- Follow all instructions and setup Cordova - https://ionicframework.com/docs/developing/android
- Java SE Development Kit 8 - https://www.oracle.com/java/technologies/javase-jdk8-downloads.html
- Android Studio is required to setup the emulator - https://developer.android.com/studio#downloads
Requirements to work with IOS Devices:
- Xcode (Available only for Apple devices)
- Follow all instructions and setup Cordova - https://ionicframework.com/docs/developing/ios#running-with-the-ionic-cli
To check if IOS and Android requirements are met:
ionic cordova requirements android
ionic cordova requirements ios
ionic serve
Angular was used to create the prototype, later Ionic was integrated for cross-platform mobile development
<!-- example taken from the c-building-floor2.page.html-->
<!-- place image within canvas -->
<img
id="floor"
#image
class="img"
draggable="false"
src="assets/images/cBuildingFloor2.png"
alt="C Building Second Floor"
usemap="#cBuildingFloor2-map"
(load)="handleMouseMove();handleMapResize()"
/>
<!-- portion of the map -->
<map name="cBuildingFloor2-map" id="map_id" #areaMap>
<!-- to display the map -->
<canvas id="mapCanvas" #canvasEl width="839" height="651"></canvas>
Every HTML page has this similar portions of this code, this must be consistent with others to prevent other issues.
Every .ts file has the following code, copy/paste these if needed and end of the file and remove when updating the app
// builds a co-ordinate list and display on screen ** debugging
public handleMouseMove() {
var img = document.getElementById("floor");
var coords = document.getElementById("coords");
img.addEventListener("mousemove", function(event) {
console.log("mouse move");
coords.innerHTML = "x: " + event.offsetX + " y: " + event.offsetY;
});
}
This code displays the X,Y coordinates on top of the header to easily draw the paths.
// onload, scales the map area cor-ordinates based on screen width
public handleMapResize() {
var ImageMap = function(map) {
console.log("scaling area maps..");
var n,
areas = map.getElementsByTagName("area"),
len = areas.length,
coords = [],
previousWidth = window.innerWidth // image original width replace with window.innerWidth when working on desktop
for (n = 0; n < len; n++) {
coords[n] = areas[n].coords.split(",");
}
this.resize = function() {
var n,
m,
clen,
x = document.body.clientWidth / previousWidth;
for (n = 0; n < len; n++) {
clen = coords[n].length;
for (m = 0; m < clen; m++) {
coords[n][m] *= x;
}
areas[n].coords = coords[n].join(",");
}
previousWidth = document.body.clientWidth;
return true;
};
window.onresize = this.resize;
},
imageMap = new ImageMap(document.getElementById("map_id"));
imageMap.resize();
}
Resizes the image based on the canvas size, avoid modifying.
previousWidth = 839 // image original width replace with window.innerWidth when working on desktop
It is important to note that whether working on Desktop or Mobile to replace otherwise screen interaction will not properly work
NOTE: Debug through browser console to determine element id, tag-name, etc
Issues with styling Ionic picker elements without its HTML counterpart will be required programmatically styled elements by retrieving its tag name and indices depending on the case
// code from home.page.ts
// within function async dBuildingFloorsPicker()
let picker = await this.pickerCtrl.create(floors);
picker.present();
setTimeout(function () {
document.getElementsByTagName("button")[3].disabled = true;
document.getElementsByTagName("button")[5].disabled = true;
document.getElementsByTagName("button")[3].style.color = "grey";
document.getElementsByTagName("button")[5].style.color = "grey";
}, 0);
A setTimeout function enables the styling before/after loading the Ionic element
- Android Emulator - https://developer.android.com/studio/run/emulator
- IOS Emulator - https://developer.apple.com/documentation/xcode/running_your_app_in_the_simulator_or_on_a_device
- Android & IOS Deploying - https://ionicframework.com/docs/v3/intro/deploying/
- Android & IOS Publishing - https://ionicframework.com/docs/v1/guide/publishing.html