Created
May 14, 2012 07:46
-
-
Save kathangeorg/2692524 to your computer and use it in GitHub Desktop.
Google Maps API bei 1und1 (BUGFIX)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* generate an array of params for a new marker icon image | |
* iconShadowImage is optional | |
* If anchor coords are not supplied, we use the center point of the image by default. | |
* Can be called statically. For private use by addMarkerIcon() and setMarkerIcon() | |
* | |
* @param string $iconImage URL to icon image | |
* @param string $iconShadowImage URL to shadow image | |
* @param string $iconAnchorX X coordinate for icon anchor point | |
* @param string $iconAnchorY Y coordinate for icon anchor point | |
* @param string $infoWindowAnchorX X coordinate for info window anchor point | |
* @param string $infoWindowAnchorY Y coordinate for info window anchor point | |
*/ | |
function createMarkerIcon($iconImage,$iconShadowImage = '',$iconAnchorX = 'x',$iconAnchorY = 'x',$infoWindowAnchorX = 'x',$infoWindowAnchorY = 'x') { | |
/*$_icon_image_path = strpos($iconImage,'http') === 0 ? $iconImage : $_SERVER['DOCUMENT_ROOT'] . $iconImage; | |
if(!($_image_info = @getimagesize($_icon_image_path))) { | |
die('GoogleMapAPI:createMarkerIcon: Error reading image: ' . $iconImage); | |
} | |
if($iconShadowImage) { | |
$_shadow_image_path = strpos($iconShadowImage,'http') === 0 ? $iconShadowImage : $_SERVER['DOCUMENT_ROOT'] . $iconShadowImage; | |
if(!($_shadow_info = @getimagesize($_shadow_image_path))) { | |
die('GoogleMapAPI:createMarkerIcon: Error reading image: ' . $iconShadowImage); | |
} | |
}*/ | |
/*BUGFIX BEGIN*/ | |
// 27.05.2011 16:45:21 auskommentiert by BlatterTech Informatik $_icon_image_path = strpos($iconImage,'http') === 0 ? $iconImage : $_SERVER['DOCUMENT_ROOT'] . $iconImage; | |
$_icon_image_path = $_SERVER['DOCUMENT_ROOT'].str_replace("http://".$_SERVER['HTTP_HOST'],"",$iconImage); | |
if(!($_image_info = @getimagesize($_icon_image_path))) { | |
die('GoogleMapAPI:createMarkerIcon: Error reading image: ' . $iconImage . ' ' .$_SERVER['HTTP_HOST'] . ' ' .$_SERVER['DOCUMENT_ROOT'] . ' ' . $_icon_image_path); | |
} | |
if($iconShadowImage) { | |
// 27.05.2011 16:45:21 auskommentiert by BlatterTech Informatik $_shadow_image_path = strpos($iconShadowImage,'http') === 0 ? $iconShadowImage : $_SERVER['DOCUMENT_ROOT'] . $iconShadowImage; | |
$_shadow_image_path = $_SERVER['DOCUMENT_ROOT'].str_replace("http://".$_SERVER['HTTP_HOST'],"",$iconShadowImage); | |
if(!($_shadow_info = @getimagesize($_shadow_image_path))) { | |
die('GoogleMapAPI:createMarkerIcon: Error reading image: ' . $iconShadowImage); | |
} | |
} | |
/*GUGFIX END*/ | |
if($iconAnchorX === 'x') { | |
$iconAnchorX = (int) ($_image_info[0] / 2); | |
} | |
if($iconAnchorY === 'x') { | |
$iconAnchorY = (int) ($_image_info[1] / 2); | |
} | |
if($infoWindowAnchorX === 'x') { | |
$infoWindowAnchorX = (int) ($_image_info[0] / 2); | |
} | |
if($infoWindowAnchorY === 'x') { | |
$infoWindowAnchorY = (int) ($_image_info[1] / 2); | |
} | |
$icon_info = array( | |
'image' => $iconImage, | |
'iconWidth' => $_image_info[0], | |
'iconHeight' => $_image_info[1], | |
'iconAnchorX' => $iconAnchorX, | |
'iconAnchorY' => $iconAnchorY, | |
'infoWindowAnchorX' => $infoWindowAnchorX, | |
'infoWindowAnchorY' => $infoWindowAnchorY | |
); | |
if($iconShadowImage) { | |
$icon_info = array_merge($icon_info, array('shadow' => $iconShadowImage, | |
'shadowWidth' => $_shadow_info[0], | |
'shadowHeight' => $_shadow_info[1])); | |
} | |
return $icon_info; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment