bug fixes
parent
8fb4f3ee49
commit
1f958c4fa7
@ -0,0 +1,7 @@
|
|||||||
|
<app-generic-header showImage="false" showBack="true" [headerText]="'itemforsale,offersdiscount' | translate">
|
||||||
|
</app-generic-header>
|
||||||
|
<ion-content>
|
||||||
|
<div #map id="map">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</ion-content>
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
#map {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { LocationComponent } from './location.component';
|
||||||
|
|
||||||
|
describe('LocationComponent', () => {
|
||||||
|
let component: LocationComponent;
|
||||||
|
let fixture: ComponentFixture<LocationComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ LocationComponent ],
|
||||||
|
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(LocationComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,79 @@
|
|||||||
|
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { HMGUtils } from 'src/app/hmg-common/hmg_utils';
|
||||||
|
import { CommonService } from 'src/app/hmg-common/services/common/common.service';
|
||||||
|
import { OfferDiscountService } from '../services/service';
|
||||||
|
declare var google;
|
||||||
|
@Component({
|
||||||
|
selector: 'app-location',
|
||||||
|
templateUrl: './location.component.html',
|
||||||
|
styleUrls: ['./location.component.scss'],
|
||||||
|
})
|
||||||
|
|
||||||
|
export class LocationComponent implements OnInit {
|
||||||
|
@ViewChild('map') mapContainer: ElementRef;
|
||||||
|
locations: any = [];
|
||||||
|
map: any;
|
||||||
|
offerDetails: any;
|
||||||
|
constructor(public hmgUtils: HMGUtils, public route: ActivatedRoute, public cs: CommonService) {
|
||||||
|
this.route
|
||||||
|
.params.subscribe(val => {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.ionEnter();
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
ionEnter() {
|
||||||
|
this.locations = this.cs.sharedService.getSharedData(OfferDiscountService.selected_offers, false);
|
||||||
|
this.offerDetails = this.cs.sharedService.getSharedData(OfferDiscountService.selected_offers, false);
|
||||||
|
this.displayMap();
|
||||||
|
}
|
||||||
|
ngOnInit() {
|
||||||
|
|
||||||
|
}
|
||||||
|
displayMap() {
|
||||||
|
|
||||||
|
const map = new google.maps.Map(
|
||||||
|
document.getElementById("map") as HTMLElement,
|
||||||
|
{
|
||||||
|
zoom: 10,
|
||||||
|
center: { lat: 24.7136, lng: 46.6753 },
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
this.setMarkers(map);
|
||||||
|
|
||||||
|
}
|
||||||
|
setMarkers(map) {
|
||||||
|
|
||||||
|
for (let i = 0; i < this.locations.length; i++) {
|
||||||
|
const loc = this.locations[i];
|
||||||
|
const infoWindow = new google.maps.InfoWindow();
|
||||||
|
var marker = new google.maps.Marker({
|
||||||
|
position: { lat: loc.latitude, lng: loc.longitude },
|
||||||
|
map,
|
||||||
|
// icon: image,
|
||||||
|
// shape: shape,
|
||||||
|
title: this.offerDetails.Title,
|
||||||
|
|
||||||
|
});
|
||||||
|
marker.addListener("click", () => {
|
||||||
|
this.cs.openLocation(loc.latitude, loc.longitude)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.hmgUtils.getCurrentLocation((resp) => {
|
||||||
|
console.log(resp);
|
||||||
|
if (resp) {
|
||||||
|
const latLng = new google.maps.LatLng(resp.latitude, resp.longitude);
|
||||||
|
const mapOptions = {
|
||||||
|
center: latLng,
|
||||||
|
zoom: 17,
|
||||||
|
mapTypeId: google.maps.MapTypeId.ROADMAP,
|
||||||
|
myLocation: true
|
||||||
|
};
|
||||||
|
|
||||||
|
this.map = new google.maps.Map(this.mapContainer.nativeElement, mapOptions);
|
||||||
|
};
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue