From e8f5a170ce3540a9f13b670661b2ae9027a7d274 Mon Sep 17 00:00:00 2001 From: Eduardo Date: Tue, 14 Jan 2020 00:24:22 +0100 Subject: [PATCH] The map that is generated based on the last one created now respects the proportions of the new figure instead of keeping the previous ones --- Map Generator.sketchplugin/Contents/Sketch/generic.js | 7 +++++++ Map Generator.sketchplugin/Contents/Sketch/google.js | 2 ++ .../Contents/Sketch/manifest.json | 2 +- Map Generator.sketchplugin/Contents/Sketch/mapbox.js | 2 ++ appcast.xml | 11 +++++++++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Map Generator.sketchplugin/Contents/Sketch/generic.js b/Map Generator.sketchplugin/Contents/Sketch/generic.js index 0e5c46f..860e242 100644 --- a/Map Generator.sketchplugin/Contents/Sketch/generic.js +++ b/Map Generator.sketchplugin/Contents/Sketch/generic.js @@ -10,10 +10,17 @@ GenericMap.prototype.generateLastMap = function (context) { return; } else { var layer = context.selection[0]; + var layerSizes = layer.frame(); var lastService = getPreferences('lastservice', ''); var lastUrl = getPreferences('lasturl', ''); var lastAddress = getPreferences('lastaddress', ''); var lastZoom = getPreferences('lastzoom', ''); + var lastWidth = getPreferences('lastwidth', ''); + var lastHeight = getPreferences('lastheight', ''); + + if (lastWidth && lastHeight) { + lastUrl = lastUrl.replace(lastWidth + 'x' + lastHeight, parseInt([layerSizes width]) + 'x' + parseInt([layerSizes height])); + } if (lastService && lastUrl && lastAddress && lastZoom) { fillLayerWithImage(lastUrl, layer, context, lastService); diff --git a/Map Generator.sketchplugin/Contents/Sketch/google.js b/Map Generator.sketchplugin/Contents/Sketch/google.js index 3dfb59d..4965c49 100644 --- a/Map Generator.sketchplugin/Contents/Sketch/google.js +++ b/Map Generator.sketchplugin/Contents/Sketch/google.js @@ -263,6 +263,8 @@ GoogleMap.prototype.generateMap = function (values, context, window) { setPreferences('lasturl', imageUrl); setPreferences('lastaddress', values.address); setPreferences('lastzoom', values.zoom); + setPreferences('lastwidth', parseInt([layerSizes width])); + setPreferences('lastheight', parseInt([layerSizes height])); fillLayerWithImage(imageUrl, layer, context, this.service); setLayerName(layer, values.address, values.zoom); diff --git a/Map Generator.sketchplugin/Contents/Sketch/manifest.json b/Map Generator.sketchplugin/Contents/Sketch/manifest.json index 878b8d0..c8f5b48 100644 --- a/Map Generator.sketchplugin/Contents/Sketch/manifest.json +++ b/Map Generator.sketchplugin/Contents/Sketch/manifest.json @@ -53,7 +53,7 @@ "icon": "icon.png", "identifier" : "io.eduardogomez.sketch.map-generator", "appcast": "https://raw.githubusercontent.com/eddiesigner/sketch-map-generator/master/appcast.xml", - "version" : "3.5.3", + "version" : "3.5.4", "description" : "Sketch plugin to fill a layer with a map generated from a given location using Google Maps and Mapbox", "authorEmail" : "this.eduardo@gmail.com", "name" : "Map Generator" diff --git a/Map Generator.sketchplugin/Contents/Sketch/mapbox.js b/Map Generator.sketchplugin/Contents/Sketch/mapbox.js index d3fc928..878ef6b 100644 --- a/Map Generator.sketchplugin/Contents/Sketch/mapbox.js +++ b/Map Generator.sketchplugin/Contents/Sketch/mapbox.js @@ -266,6 +266,8 @@ MapboxMap.prototype.generateMap = function (values, context, window) { setPreferences('lasturl', imageUrl); setPreferences('lastaddress', values.address); setPreferences('lastzoom', values.zoom); + setPreferences('lastwidth', parseInt([layerSizes width])); + setPreferences('lastheight', parseInt([layerSizes height])); fillLayerWithImage(imageUrl, layer, context, this.service); setLayerName(layer, values.address, values.zoom); diff --git a/appcast.xml b/appcast.xml index e3e845c..af28f9f 100644 --- a/appcast.xml +++ b/appcast.xml @@ -199,5 +199,16 @@ + + Version 3.5.4 + + +
  • 🛠 The map that is generated based on the last one created now respects the proportions of the new figure instead of keeping the previous ones.
  • + + ]]> +
    + +