From a4101d52cfe8c20c61ef72a3ba53bdbf02cc2a66 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Thu, 6 Feb 2014 05:47:34 +0100 Subject: [PATCH] Create styles only once --- examples/google-map.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/google-map.js b/examples/google-map.js index 53ee9fa843..643a97a57a 100644 --- a/examples/google-map.js +++ b/examples/google-map.js @@ -35,8 +35,8 @@ google.maps.event.addListenerOnce(gmap, 'tilesloaded', function() { url: 'data/geojson/countries.geojson', projection: 'EPSG:3857' }), - styleFunction: function(feature, resolution) { - return [new ol.style.Style({ + styleFunction: (function() { + var styleArray = [new ol.style.Style({ fill: new ol.style.Fill({ color: 'rgba(255, 255, 255, 0.6)' }), @@ -45,7 +45,10 @@ google.maps.event.addListenerOnce(gmap, 'tilesloaded', function() { width: 1 }) })]; - } + return function(feature, resolution) { + return styleArray; + }; + }()) }); var center = gmap.getCenter();