diff --git a/src/pages/CaseFlag.vue b/src/pages/CaseFlag.vue
index b6a42c739..ec6cc949b 100644
--- a/src/pages/CaseFlag.vue
+++ b/src/pages/CaseFlag.vue
@@ -151,6 +151,7 @@
{{ $t('flag.click_if_location_unknown') }} @@ -406,6 +407,10 @@ export default { this.incidents = orderBy(response.data.results, ['id'], ['desc']); }, methods: { + spliceUrl(url) { + // eslint-disable-next-line prefer-destructuring + this.currentFlag.requested_action = url.split('data')[0]; + }, async flagWorksite() { if ( this.currentFlag.reason_t === 'flag.worksite_wrong_incident' && diff --git a/src/utils/__tests__/map.test.js b/src/utils/__tests__/map.test.js new file mode 100644 index 000000000..19fb05f04 --- /dev/null +++ b/src/utils/__tests__/map.test.js @@ -0,0 +1,14 @@ +import { getGoogleMapsLocation } from '../map'; + +describe('Google Maps Parse', () => { + const coords = { + lat: 38.8976763, + long: -77.0387185, + }; + + const url = + 'https://www.google.com/maps/place/white+house/@38.8976763,-77.0387185,17z/data=!3m1!4b1!4m5!3m4!1s0x89b7b7bcdecbb1df:0x715969d86d0b76bf!8m2!3d38.8976763!4d-77.0365298'; + test('Gets Correct Latitude and Longitude', () => { + expect(getGoogleMapsLocation(url) === coords); + }); +}); diff --git a/src/utils/map.js b/src/utils/map.js index f0afc0dc0..f12b4b1de 100644 --- a/src/utils/map.js +++ b/src/utils/map.js @@ -34,10 +34,10 @@ export const mapAttribution = '© OpenStreetMap contributors, © CartoDB'; export const getGoogleMapsLocation = (url) => { - const regex = new RegExp('@(.*),(.*),'); - const match = url.match(regex); - const latitude = Number(match[1]); - const longitude = Number(match[2]); + const regex = '@(-?\\d+\\.\\d+),(-?\\d+\\.\\d+),(\\d+\\.?\\d?)+z'; + const match = url.matchAll(regex); + const latitude = match[0]; + const longitude = match[1]; return { longitude,