Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
createMap() {
// TODO need to store/retrieve prevLoc in app preferences/local storage
let prevLoc = new LatLng(13.0768342, 77.7886087);
let mapOptions: GoogleMapOptions = {
camera: {
target: prevLoc,
zoom: 15,
tilt: 10
}
};
this.map = GoogleMaps.create('map', mapOptions);
this.map.one(GoogleMapsEvent.MAP_READY).then(() => {
console.log('--> ReportNewPage: Map is Ready To Use');
this.mapReady = true;
// https://stackoverflow.com/questions/4537164/google-maps-v3-set-single-marker-point-on-map-click
this.map.on(GoogleMapsEvent.MAP_CLICK).subscribe( event => {
this.location = event[0];
console.log('--> ReportNewPage: User clicked location = ' + event[0]);
this.map.clear();
(locations: any) => {
// process all markers
for (var i = 0; i < locations.length; i++) {
let location = locations[i];
// create new marker
let markerOptions: MarkerOptions = {
position: new LatLng(location.outlet_latitude, location.outlet_longitude),
title: location.outlet_business,
snippet: `${location.outlet_name}, ${location.outlet_suburb}, ${location.outlet_postcode}`+
`\r\nMonday: ${location.outlet_business_hour_mon !== null ? location.outlet_business_hour_mon : "N/A"}`+
`\r\nTuesday: ${location.outlet_business_hour_tue !== null ? location.outlet_business_hour_tue : "N/A"}`+
`\r\nWednesday: ${location.outlet_business_hour_wed !== null ? location.outlet_business_hour_wed : "N/A"}`+
`\r\nThursday: ${location.outlet_business_hour_thur !== null ? location.outlet_business_hour_thur : "N/A"}`+
`\r\nFriday: ${location.outlet_business_hour_fri !== null ? location.outlet_business_hour_fri : "N/A"}`+
`\r\nSaturday: ${location.outlet_business_hour_sat !== null ? location.outlet_business_hour_sat : "N/A"}`+
`\r\nSunday: ${location.outlet_business_hour_sun !== null ? location.outlet_business_hour_sun : "N/A"}`
};
// add marker to list to be added
this.map.addMarker(markerOptions);
}
loader.dismiss();
}
, error => {
loadMap() {
let loc = new LatLng(this.grievance.geoLocation.coordinates[1], this.grievance.geoLocation.coordinates[0]);
let mapOptions: GoogleMapOptions= {
camera: {
target: loc,
zoom: 15,
tilt: 10
}
};
this.map = GoogleMaps.create('map', mapOptions);
this.map.one(GoogleMapsEvent.MAP_READY).then(() => {
this.map.addMarker({
title: 'Problem Location',
position: loc
}).then((marker: Marker) => {
marker.showInfoWindow();
}).catch(err => {
console.log(err);
private addDeviceMarker(lat: number, lng: number, address: string, title: string) {
let latLng = new LatLng(lat, lng);
let markerOptions: MarkerOptions = {
position: latLng,
title: title,
snippet: address
};
this.map.addMarker(markerOptions).then(
(marker: Marker) => {
marker.showInfoWindow();
this.markers.push(marker);
this.setCenteredMarkerOnDevice(title, lat, lng);
});
}
addMarker(marker: IonMarker) {
const { lat, lng, iconUrl, title,
animated, draggable, visible,
zIndex } = marker;
const markerOptions: MarkerOptions = {
position: new LatLng(lat, lng),
title,
icon: iconUrl,
animation: animated ? GoogleMapsAnimation.DROP : null,
zIndex,
draggable,
visible
};
return this.map.addMarker(markerOptions);
}
}
.then((position) => new LatLng(position.coords.latitude, position.coords.longitude));
}
this.geolocation.getCurrentPosition().then((position) => {
const latLng: LatLng = new LatLng(position.coords.latitude, position.coords.longitude);
resolve(latLng);
}, error => {
reject(error);
this.markers.map((marker) => {
if(marker.getTitle() == title) {
let latLng = new LatLng(lat, lng);
let camPos: CameraPosition = {
target: latLng,
zoom: 15
};
this.map.moveCamera(camPos);
}
});
}