Permalink
Browse files

add _place_calculate_zoom function; update maps accordingly

  • Loading branch information...
1 parent f54b751 commit 6db6a4ffea82f9e4551e88e2110d6efde48db9aa @thisisaaronland thisisaaronland committed Nov 26, 2011
@@ -29,6 +29,38 @@ function flickr_places_is_valid_placetype($type){
#################################################################
+ function flickr_places_calculate_zoom(&$place){
+
+ $placetype = $place['place_type'];
+
+ # TO DO: put this is all in a big map hash, probably,
+ # but since we don't need it now just leave this as
+ # is. Also check for "Brooklyn", and other special
+ # cases here. (20111126/straup)
+
+ if ($placetype=='country'){
+ return 3;
+ }
+
+ if ($placetype=='region'){
+ return 5;
+ }
+
+ if ($placetype=='county'){
+ return 8;
+ }
+
+ if ($placetype=='locality'){
+ return 11;
+ }
+
+ # neighbourhood
+
+ return 12;
+ }
+
+ #################################################################
+
# Okay, stop for a second. Normally we would just cache this sort
# of thing (fetching data from a third-party API) using memcache
# or similar. Although it might be overkill there's no particular
@@ -1,10 +1,11 @@
{capture assign="page_title"}{$owner.username} | photos from {$place.name}{/capture}
{include file="inc_head.txt"}
-{* TO DO: either get place extent or calculate zoom by place type... *}
{* TO DO: figure out why safari doesn't honour the .place_map css definition... *}
-<div class="map place_map" data-provider="{$cfg.slippymap_provider|escape}" data-center="{$place.latitude|escape},{$place.longitude|escape}" data-zoom="12" data-interactive="false" id="map_{$photo.id|escape}" style="width:100%;">
+{assign var="zoom" value=$place|@flickr_places_calculate_zoom}
+
+<div class="map place_map" data-provider="{$cfg.slippymap_provider|escape}" data-center="{$place.latitude|escape},{$place.longitude|escape}" data-zoom="{$zoom|escape}" data-interactive="false" id="map_{$photo.id|escape}" style="width:100%;">
{foreach from=$photos item="photo"}
<div class="marker" data-location="{$photo.latitude|escape},{$photo.longitude|escape}">
@@ -32,9 +32,9 @@ Your most geotagged {$facet_plural|escape}
{assign var="max_maps" value=15}
{foreach from=$facets item="count" key="woeid" name="places"}
-
{if $smarty.foreach.places.index < $max_maps}
-<div class="map place_map" data-provider="{$cfg.slippymap_provider|escape}" data-center="{$locations.$woeid.latitude|escape},{$locations.$woeid.longitude|escape}" data-zoom="11" data-interactive="false" style="width:100%;">
+{assign var="zoom" value=$locations.$woeid|@flickr_places_calculate_zoom}
+<div class="map place_map" data-provider="{$cfg.slippymap_provider|escape}" data-center="{$locations.$woeid.latitude|escape},{$locations.$woeid.longitude|escape}" data-zoom="{$zoom|escape}" data-interactive="false" style="width:100%;">
<div class="marker" style="border-radius:0 !important;" data-location="{$locations.$woeid.latitude|escape},{$locations.$woeid.longitude|escape}">{$locations.$woeid.name|escape}</div>

0 comments on commit 6db6a4f

Please sign in to comment.