Skip to content

Commit

Permalink
Fixed error when icon url for markers
Browse files Browse the repository at this point in the history
  • Loading branch information
eperedo committed Jul 16, 2017
1 parent d74a18e commit b8fa8ad
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 13 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
![static google map](https://user-images.githubusercontent.com/461124/28100714-6c896d1e-6689-11e7-8a38-327dfe4b6ff5.png)

[Google Documentation](https://developers.google.com/maps/documentation/static-maps/intro)

## Demo

- [JSBin example](http://jsbin.com/gawedufesa/edit?html,js,output)
- [JSBin example](http://jsbin.com/gizixekilu/edit?html,js,output)

## Requirements

Expand Down
2 changes: 1 addition & 1 deletion dist/StaticMap.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/StaticMap.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-static-map",
"version": "1.6.3",
"version": "2.0.0",
"description": "a simple component to generate static google map",
"keywords": [
"vue",
Expand Down
6 changes: 3 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export default {
data: () => {
const dataValues = {
apiKey: '',
center: 'Empire State Building',
center: 'Brooklyn+Bridge,New+York,NY',
format: 'gif',
language: 'EN',
language: 'ja',
markers: [
{
label: 'B', color: 'blue', lat: 40.702147, lng: -74.015794, size: 'normal',
label: 'W', color: 'blue', lat: 40.702147, lng: -74.015794, size: 'normal',
},
{
label: 'Y', color: 'yellow', lat: 40.711614, lng: -74.012318, size: 'tiny',
Expand Down
26 changes: 21 additions & 5 deletions src/components/StaticMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,28 @@ function generateMapUrl() {
function generateMarkers() {
const markers = this.markers.map((marker) => {
const color = `color:${marker.color}`;
const size = `size:${marker.size}`;
const label = `label:${marker.label}`;
const icon = `icon:${marker.icon}`;
const color = `color:${marker.color}|`;
const size = `size:${marker.size}|`;
const label = `label:${marker.label}|`;
const icon = `icon:${marker.icon}|`;
const latLng = `${marker.lat},${marker.lng}`;
const markerUrl = `&markers=${icon}|${size}|${color}|${label}|${latLng}`;
let markerUrl = '&markers=';
if (marker.color) {
markerUrl += color;
}
if (marker.size) {
markerUrl += size;
}
if (marker.label) {
markerUrl += label;
}
if (marker.icon) {
markerUrl += icon;
}
if (marker.lat && marker.lng) {
markerUrl += latLng;
}
// const markerUrl = `&markers=${icon}|${size}|${color}|${label}|${latLng}`;
return markerUrl;
});
return markers.join('');
Expand Down

0 comments on commit b8fa8ad

Please sign in to comment.