forked from xkjyeah/vue-google-maps
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gmap-vue): add a heatmap layer component (#8)
* Add a Heatmap Layer component * Fix typo left over from discrete component implementation * fix(gmap-vue): update packages/gmap-vue/examples/heatmap-layer.html * fix(gmap-vue): update packages/gmap-vue/examples/heatmap-layer.html * fix(gmap-vue): update packages/gmap-vue/examples/heatmap-layer.html * fix(gmap-vue): update packages/gmap-vue/examples/heatmap-layer.html * fix(gmap-vue): update packages/gmap-vue/examples/heatmap-layer.html * fix(gmap-vue): update packages/gmap-vue/src/components/heatmap-layer.js * fix(gmap-vue): update packages/gmap-vue/src/components/heatmap-layer.js Co-authored-by: Diego A. Zapata Häntsch <diegoazh2003@gmail.com>
- Loading branch information
1 parent
19e3a1c
commit 5d7d9c0
Showing
3 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<body> | ||
<div id="root"> | ||
<button @click="setMarkers"> | ||
Set markers on heatmap | ||
</button> | ||
<br><br> | ||
<gmap-map ref="mapRef" :zoom="7" :center="center" map-type-id="roadmap" style="width: 100%; height: 500px"> | ||
<gmap-marker v-for="(m, index) in markers" :key="index" :position="m.location" :clickable="true" :draggable="true" @click="center=m.location" /> | ||
<gmap-heatmap-layer :data="markers" :options="{maxIntensity: 120, dissipating: false}" /> | ||
</gmap-map> | ||
</div> | ||
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> | ||
<script src="gmap-vue.js"></script> | ||
|
||
<script> | ||
|
||
Vue.use(GmapVue, { | ||
load: { | ||
key: 'AIzaSyDf43lPdwlF98RCBsJOFNKOkoEjkwxb5Sc', | ||
libraries: 'visualization' | ||
}, | ||
}); | ||
|
||
document.addEventListener('DOMContentLoaded', function () { | ||
new Vue({ | ||
el: '#root', | ||
data: { | ||
center: {lat:4.5, lng: 99}, | ||
markers: [], | ||
}, | ||
methods: { | ||
setMarkers() { | ||
this.markers = [ | ||
{ location: new google.maps.LatLng({ lat: 3, lng: 101 }), weight: 100 }, | ||
{ location: new google.maps.LatLng({ lat: 5, lng: 99 }), weight: 50 }, | ||
{ location: new google.maps.LatLng({ lat: 6, lng: 97 }), weight: 80 }, | ||
]; | ||
} | ||
}, | ||
}); | ||
}); | ||
|
||
</script> | ||
|
||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import mapElementFactory from '../factories/map-element' | ||
|
||
const props = { | ||
options: { | ||
type: Object, | ||
twoWay: false, | ||
default: () => {}, | ||
}, | ||
data: { | ||
type: Array, | ||
twoWay: true | ||
}, | ||
}; | ||
|
||
const events = []; | ||
|
||
/** | ||
* @class Heatmap Layer | ||
* | ||
* Heatmap Layer class | ||
*/ | ||
export default mapElementFactory({ | ||
mappedProps: props, | ||
events, | ||
name: 'heatmapLayer', | ||
ctr: () => google.maps.visualization.HeatmapLayer | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters