poly-js-utils
Advanced tools
Comparing version 1.1.3 to 1.1.4
{ | ||
"name": "poly-js-utils", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Common client-side tools used in HSS Sites themes and locators.", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
@@ -15,2 +15,5 @@ /******************/ | ||
var googleGeocodeAddress = function(address, callback) { | ||
if(typeof google !== 'object' || typeof google.maps !== 'object') { | ||
callback(false, "Unable to load Google API script."); | ||
} | ||
var geocoder = new google.maps.Geocoder(); | ||
@@ -38,36 +41,38 @@ var string = address; | ||
var showGoogleMap = function(latlng, containerID, useDefaultMarker, options) { | ||
latlng = latlng || []; | ||
useDefaultMarker = useDefaultMarker === undefined ? true : useDefaultMarker; | ||
var defaults = { | ||
zoom: DEFAULT_ZOOM_LEVEL, | ||
mapTypeControl: false, | ||
scrollwheel: false, | ||
disableDefaultUI: false, | ||
disableDoubleClickZoom: false, | ||
draggable: true | ||
}; | ||
options = _.extend(defaults, options); | ||
// Set center, defaulting to empty gmaps LatLng object. | ||
options.center = latlng.length ? | ||
{lat: latlng[0], lng: latlng[1]} : new google.maps.LatLng(); | ||
if(typeof google === 'object' && typeof google.maps === 'object') { | ||
latlng = latlng || []; | ||
useDefaultMarker = useDefaultMarker === undefined ? true : useDefaultMarker; | ||
var defaults = { | ||
zoom: DEFAULT_ZOOM_LEVEL, | ||
mapTypeControl: false, | ||
scrollwheel: false, | ||
disableDefaultUI: false, | ||
disableDoubleClickZoom: false, | ||
draggable: true | ||
}; | ||
options = _.extend(defaults, options); | ||
// Set center, defaulting to empty gmaps LatLng object. | ||
options.center = latlng.length ? | ||
{lat: latlng[0], lng: latlng[1]} : new google.maps.LatLng(); | ||
// Only have one map per container. | ||
var map = _googleMaps[containerID]; | ||
if (!map) { | ||
map = new google.maps.Map(document.getElementById(containerID), options); | ||
_googleMaps[containerID] = map; | ||
} else { | ||
// Force a resize so that we don't see missing tiles | ||
google.maps.event.trigger(map, "resize"); | ||
} | ||
map.setOptions(options); | ||
// Only have one map per container. | ||
var map = _googleMaps[containerID]; | ||
if (!map) { | ||
map = new google.maps.Map(document.getElementById(containerID), options); | ||
_googleMaps[containerID] = map; | ||
} else { | ||
// Force a resize so that we don't see missing tiles | ||
google.maps.event.trigger(map, "resize"); | ||
} | ||
map.setOptions(options); | ||
// Don't show default marker if we don't have a latlng to place it at. | ||
if (useDefaultMarker && latlng) { | ||
new google.maps.Marker({ | ||
position: options.center, | ||
map: map | ||
}); | ||
// Don't show default marker if we don't have a latlng to place it at. | ||
if (useDefaultMarker && latlng) { | ||
new google.maps.Marker({ | ||
position: options.center, | ||
map: map | ||
}); | ||
} | ||
return map; | ||
} | ||
return map; | ||
}; | ||
@@ -74,0 +79,0 @@ |
89628
1926