From 4ca046914d64b19c5d972496f2c7e66209275937 Mon Sep 17 00:00:00 2001 From: Joe Germuska Date: Mon, 16 Jun 2014 17:05:13 -0500 Subject: [PATCH] try to parse new google maps urls. Still don't know how to decode data parameter. see #638 --- source/js/Core/Media/VMM.ExternalAPI.js | 40 +++++++++++++++---------- source/js/Core/Media/VMM.MediaType.js | 4 +++ 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/source/js/Core/Media/VMM.ExternalAPI.js b/source/js/Core/Media/VMM.ExternalAPI.js index bbb8468..47e650f 100644 --- a/source/js/Core/Media/VMM.ExternalAPI.js +++ b/source/js/Core/Media/VMM.ExternalAPI.js @@ -514,22 +514,32 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') { layer = google.maps.MapTypeId['TERRAIN']; } - - if (type.of(VMM.Util.getUrlVars(m.id)["ll"]) == "string") { - has_location = true; - latlong = VMM.Util.getUrlVars(m.id)["ll"].split(","); - location = new google.maps.LatLng(parseFloat(latlong[0]),parseFloat(latlong[1])); + var new_google_url_regex = new RegExp(/@([0-9\.\-]+),([0-9\.\-]+),(\d+)z/); + + if (m.id.match(new_google_url_regex)) { + var match = m.id.match(new_google_url_regex) + lat = parseFloat(match[1]); + lng = parseFloat(match[2]); + location = new google.maps.LatLng(lat,lng); + zoom = parseFloat(match[3]); + has_location = has_zoom = true; + } else { + if (type.of(VMM.Util.getUrlVars(m.id)["ll"]) == "string") { + has_location = true; + latlong = VMM.Util.getUrlVars(m.id)["ll"].split(","); + location = new google.maps.LatLng(parseFloat(latlong[0]),parseFloat(latlong[1])); + + } else if (type.of(VMM.Util.getUrlVars(m.id)["sll"]) == "string") { + latlong = VMM.Util.getUrlVars(m.id)["sll"].split(","); + location = new google.maps.LatLng(parseFloat(latlong[0]),parseFloat(latlong[1])); + } + + if (type.of(VMM.Util.getUrlVars(m.id)["z"]) == "string") { + has_zoom = true; + zoom = parseFloat(VMM.Util.getUrlVars(m.id)["z"]); + } + } - } else if (type.of(VMM.Util.getUrlVars(m.id)["sll"]) == "string") { - latlong = VMM.Util.getUrlVars(m.id)["sll"].split(","); - location = new google.maps.LatLng(parseFloat(latlong[0]),parseFloat(latlong[1])); - } - - if (type.of(VMM.Util.getUrlVars(m.id)["z"]) == "string") { - has_zoom = true; - zoom = parseFloat(VMM.Util.getUrlVars(m.id)["z"]); - } - map_options = { zoom: zoom, draggable: false, diff --git a/source/js/Core/Media/VMM.MediaType.js b/source/js/Core/Media/VMM.MediaType.js index c2cd22d..071aa33 100644 --- a/source/js/Core/Media/VMM.MediaType.js +++ b/source/js/Core/Media/VMM.MediaType.js @@ -88,6 +88,10 @@ if(typeof VMM != 'undefined' && typeof VMM.MediaType == 'undefined') { media.type = "google-map"; media.id = d.split(/src=['|"][^'|"]*?['|"]/gi); success = true; + } else if (d.match(/www.google.\w+\/maps/)) { + media.type = "google-map"; + media.id = d; + success = true; } else if (d.match("plus.google")) { media.type = "googleplus"; media.id = d.split("/posts/")[1];