gpt4 book ai didi

google-maps - Google 静态 map - 画一个圆圈

转载 作者:行者123 更新时间:2023-12-02 17:28:33 27 4
gpt4 key购买 nike

尝试创建一个带圆圈的静态 map ,如 this

enter image description here

path参数中,我不明白如何获取enc部分。这似乎是一些编码路径,包括圆的纬度/经度和大小。

https://maps.googleapis.com/maps/api/staticmap?
center=51.44208,5.47308&
zoom=14&
size=693x648&
path=color:blue|fillcolor:0x00d2c196|weight:1|
enc%3Aad_yHofn%60%40JyFh%40sF%60AcFxAmElBqD~BoCnCiBtC_AzCUzCTvC~%40lChB~BnCnBpDxAlE%60AbFf%40rFLxFMxFg%40rFaAbFyAlEoBpD_CnCmChBwC~%40%7BCT%7BCUuC_AoCiB_CoCmBqDyAmEaAcFi%40sFKyF%3F%3F

Link to Google's documentation

**编辑:找到这些:

Drawing a circle Google Static Maps

Encoded Polyline Algorithm Format

最佳答案

这是我想出的:

function funcStaticMapWithCircle($lat, $lng) {

//$lat & $lng are center of circle

$mapCentLat = $lat + 0.002;
$mapCentLng = $lng - 0.011;
$mapW = 600;
$mapH = 600;
$zoom = 14;

$circRadius = 0.75; //Radius in km
$circRadiusThick = 1;
$circFill = '00BFFF';
$circFillOpacity = '60';
$circBorder = 'red';

$encString = GMapCircle($lat,$lng,$circRadius); //Encoded polyline string


$src = 'https://maps.googleapis.com/maps/api/staticmap?';
$src .= 'center=' .$mapCentLat. ',' .$mapCentLng. '&';
$src .= 'zoom=' .$zoom. '&';
$src .= 'size=' .$mapW. 'x' .$mapH.'&';
$src .= 'maptype=roadmap&';
$src .= 'style=feature:water|element:geometry.fill|color:0x9bd3ff&';
$src .= 'path=';
$src .= 'color:0x' .$circBorder. '00|';
$src .= 'fillcolor:0x' .$circFill.$circFillOpacity. '|';
$src .= 'weight:' .$circRadiusThick. '|';
$src .= 'enc:' .$encString;


return $src;
}

GMapCircle 函数来自:Drawing a circle Google Static Maps

关于google-maps - Google 静态 map - 画一个圆圈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36506668/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com