|
16 | 16 |
|
17 | 17 | <p-growl :value="msgs"></p-growl> |
18 | 18 |
|
19 | | - <p-gmap ref="gmap" :style="{'width':'100%','height':'320px'}" :options="options" :overlays="overlays" |
20 | | - @onMapClick="handleMapClick($event)" @onOverlayClick="handleOverlayClick($event)" @onOverlayDragEnd="handleDragEnd($event)"></p-gmap> |
21 | | - <p-button type="button" label="Clear" icon="fa-close" @click="clear()" style="margin-top:10px"></p-button> |
22 | | - <p-button type="button" label="Zoom In" icon="fa-search-plus" @click="zoomIn(gmap.getMap())" style="margin-top:10px"></p-button> |
23 | | - <p-button type="button" label="Zoom Out" icon="fa-search-minus" @click="zoomOut(gmap.getMap())" style="margin-top:10px"></p-button> |
| 19 | + <p-gmap ref="gmap" |
| 20 | + :style="{'width':'100%','min-height':'320px'}" |
| 21 | + :options="options" |
| 22 | + :overlays="overlays" |
| 23 | + @click="handleMapClick" |
| 24 | + @overlayclick="handleOverlayClick" |
| 25 | + @overlaydragend="handleDragEnd"> |
| 26 | + </p-gmap> |
| 27 | + <p-button type="button" label="Clear" icon="fa-close" |
| 28 | + @click="clear()" style="margin-top:10px"></p-button> |
| 29 | + <p-button type="button" label="Zoom In" icon="fa-search-plus" |
| 30 | + @click="zoomIn($refs.gmap.getMap())" style="margin-top:10px"></p-button> |
| 31 | + <p-button type="button" label="Zoom Out" icon="fa-search-minus" |
| 32 | + @click="zoomOut($refs.gmap.getMap())" style="margin-top:10px"></p-button> |
24 | 33 |
|
25 | 34 | </div> |
26 | 35 | </div> |
27 | 36 | </template> |
28 | 37 | <script> |
| 38 | + const google = window.google; |
29 | 39 | export default { |
30 | 40 | name: 'gmapdemo', |
31 | 41 | data () { |
|
44 | 54 | handleMapClick (event) { |
45 | 55 | this.dialogVisible = true; |
46 | 56 | this.selectedPosition = event.latLng; |
| 57 | + alert(event.latLng); |
47 | 58 | }, |
48 | 59 | handleOverlayClick (event) { |
49 | | - this.msgs = []; |
50 | | - let isMarker = event.overlay.getTitle != undefined; |
| 60 | + // this.msgs = []; |
| 61 | + let isMarker = typeof event.overlay.getTitle !== 'undefined'; |
51 | 62 | if(isMarker) { |
52 | 63 | let title = event.overlay.getTitle(); |
53 | 64 | this.infoWindow.setContent('' + title + ''); |
54 | 65 | this.infoWindow.open(event.map, event.overlay); |
55 | 66 | event.map.setCenter(event.overlay.getPosition()); |
56 | | - this.msgs.push({severity:'info', summary:'Marker Selected', detail: title}); |
| 67 | + // this.msgs.push({severity:'info', summary:'Marker Selected', detail: title}); |
57 | 68 | } else { |
58 | | - this.msgs.push({severity:'info', summary:'Shape Selected', detail: ''}); |
| 69 | + // this.msgs.push({severity:'info', summary:'Shape Selected', detail: ''}); |
59 | 70 | } |
60 | 71 | }, |
61 | 72 | addMarker () { |
62 | | - this.overlays.push(new google.maps.Marker({position:{lat: this.selectedPosition.lat(), lng: this.selectedPosition.lng()}, title:this.markerTitle, draggable: this.draggable})); |
| 73 | + this.overlays.push(new google.maps.Marker({ |
| 74 | + position: { |
| 75 | + lat: this.selectedPosition.lat(), |
| 76 | + lng: this.selectedPosition.lng() |
| 77 | + }, |
| 78 | + title: this.markerTitle, |
| 79 | + draggable: this.draggable |
| 80 | + })); |
63 | 81 | this.markerTitle = null; |
64 | 82 | this.dialogVisible = false; |
65 | 83 | }, |
66 | 84 | handleDragEnd (event) { |
67 | | - this.msgs = []; |
68 | | - this.msgs.push({severity:'info', summary:'Marker Dragged', detail: event.overlay.getTitle()}); |
| 85 | + let title = event.overlay.getTitle(); |
| 86 | + alert('Dragged: ' + title); |
| 87 | + // this.msgs = []; |
| 88 | + // this.msgs.push({severity:'info', summary:'Marker Dragged', detail: event.overlay.getTitle()}); |
69 | 89 | }, |
70 | 90 | initOverlays () { |
71 | 91 | if (!this.overlays || !this.overlays.length) { |
72 | 92 | this.overlays = [ |
73 | | - new google.maps.Marker({position: {lat: 14.6188043, lng: 79.9630253}, title: 'Talamanchi'}), |
74 | | - new google.maps.Marker({position: {lat: 14.4290442, lng: 79.9456852}, title: 'Nellore'}), |
| 93 | + new google.maps.Marker({position: {lat: 14.6188043, lng: 79.9630253}, title: 'Talamanchi', draggable: true }), |
| 94 | + new google.maps.Marker({position: {lat: 14.4290442, lng: 79.9456852}, title: 'Nellore', draggable: true }), |
75 | 95 | new google.maps.Polygon({paths: [ |
76 | 96 | {lat: 14.1413809, lng: 79.8254154}, {lat: 11.1513809, lng: 78.8354154}, |
77 | 97 | {lat: 15.1313809, lng: 78.8254154}, {lat: 15.1613809, lng: 79.8854154} |
|
85 | 105 | } |
86 | 106 | }, |
87 | 107 | zoomIn (map) { |
88 | | - map.setZoom(map.getZoom()+1); |
| 108 | + map.setZoom(map.getZoom() + 1); |
89 | 109 | }, |
90 | 110 | zoomOut (map) { |
91 | | - map.setZoom(map.getZoom()-1); |
| 111 | + map.setZoom(map.getZoom() - 1); |
92 | 112 | }, |
93 | 113 | clear () { |
94 | 114 | this.overlays = []; |
|
0 commit comments