-
-
Save mtermoul/5bbbc37f8e6c5a92fe98c1e47b5486a8 to your computer and use it in GitHub Desktop.
MapPanel view how to update the map and add markers.
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
methods: { | |
... | |
updateMapCenter (location) { | |
this.mapMarkers = null | |
setTimeout(() => { | |
this.mapCenter.lat = location.geoPoint.latitude | |
this.mapCenter.lng = location.geoPoint.longitude | |
this.zoom = 11 | |
this.addMapMarkers() | |
}, 500) | |
}, | |
addMapMarkers () { | |
// go through the stores list and add a map marker for each | |
let markers = {} | |
for (let i = 0; i < this.stores.length; i++) { | |
const marker = {} | |
marker.id = this.stores[i].id | |
marker.title = this.stores[i].displayName + '\n' + this.stores[i].address.address + '\n' + | |
this.stores[i].phone | |
marker.animation = 4 | |
marker.position = { | |
lat: this.stores[i].geoPoint.latitude, | |
lng: this.stores[i].geoPoint.longitude | |
} | |
marker.icon = {url: this.mapIcons.defaultIcon, scaledSize: this.mapMarkerIconSize} | |
markers[this.stores[i].id] = marker | |
} | |
this.mapMarkers = markers | |
}, | |
... | |
selectMapMarker (id, isOn) { | |
// will make the specified id marker either heilighted or not | |
if (this.mapMarkers && this.mapMarkers[id]) { | |
const url = isOn ? this.mapIcons.selectedIcon : this.mapIcons.defaultIcon | |
const icon = {url: url, scaledSize: this.mapMarkerIconSize} | |
this.mapMarkers[id].icon = icon | |
if (isOn) { | |
const storeLocation = Object.assign({}, this.mapMarkers[id].position) | |
this.centerOnStore(storeLocation) | |
} | |
} | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment