0

0

php google api 接口程序

php中文网

php中文网

发布时间:2016-05-25 16:38:37

|

1121人浏览过

|

来源于php中文网

原创

常用的google地图开发参数

phproogle::apiKey

.这是谷歌的用户API密钥,这也可以设置使用时,一个新的实例是instanciated构造.

phproogle::addGoogleMapControl() phproogle::addGoogleMapControl()

此方法设置,如缩放控制控制器的谷歌地图,地图控制等此方法可以多次调用设置地图多个控件,Options are:选项有:

立即学习PHP免费学习笔记(深入)”;

* GLargeMapControl GLargeMapControl

* GSmallMapControl GSmallMapControl

* GSmallZoomControl GSmallZoomControl

* GScaleControl GScaleControl

* GMapTypeControl GMapTypeControl

* GHierarchicalMapTypeControl GHierarchicalMapTypeControl

* GOverviewMapControl GOverviewMapControl

addGoogleMapControl ( "GSmallMapControl" ); ?> 

phproogle::mapType phproogle::mapType

This sets the map type to one of four options:这将设置地图类型的四个选项之一:

* normal正常

* satellite卫星

* hybrid混合

* physical物理

mapType = "normal" ; ?> 

phproogle::mapCenter phproogle::mapCenter

T这将设置分区范围内的地图中心,该值是一个包含的纬度和经度的地图中心的顺序.

$map->mapCenter = array(-33.862828, 151.216974); 1 $map->mapCenter = array(-33.862828, 151.216974); 1 

phproogle::mapZoom phproogle::mapZoom

这将设置地图缩放级别。 零值是最广泛的缩放级别,并显示整个世界。 虽然19日是最高变焦,将显示建筑物。 Each zoom level doubles the zoom.每个缩放级别的两倍变焦。 12.默认值为12。 

phproogle::addMarker() phproogle::addMarker()

天天团购系统
天天团购系统

天天团购系统是一套强大的开源团购程序,采用PHP+mysql开发,系统内置支付宝、财付通、GOOGLE地图等接口,支持短信发送团购券和实物团购快递发货等;另外可通过Ucenter模块,与网站已有系统无缝整合,实现用户同步注册、登陆、退出。 天天团购系统是一套创新的开源团购程序,拥有多达10项首创功能,同时支持虚拟和实物团购,内置类似淘宝的快递配送体系,并提供强大的抽奖、邀请返利等营销功能,让您轻松

下载

This function is used to create and place markers upon the map.这个函数用于创建和地点后,地图标记。 the addMarker method takes three args.在addMarker argS的方法有三个。

* float $latitude浮动$纬度

* float $longitude浮动$经度

* string $html字符串$的HTML

.经度和纬度都是数字值和HTML可以是任何HTML或文本将在标记球囊内。 

phproogle::addMarkerAddress() phproogle::addMarkerAddress()

此方法类似于phproogle::addMarker()和地方在地图上的标记。 然而,而不是接受经度和纬度来放置标志,这种方法需要两个值。

* string $address字符串$地址

* string $html字符串$的HTML

参数的地址,如"二街宫人至法国巴黎简单的地址"。  balloon.在HTML参数再次,任何文本或HTML放置在信息气球。 

phproogle::mapDivID phproogle::mapDivID

当设置,这将设置组ID的映射居住于默认值是"地图" 

phproogle::mapWidth phproogle::mapWidth

顾名思义,这将设置div的宽度该地图居住于默认宽度为350像素。 

phproogle::mapHeight phproogle::mapHeight

这将设置分区的高度该地图居住于默认值是300像素。 

phproogle::googleJS() phproogle::googleJS()

此方法返回的JavaScript字符串,用于在文件头,显示与谷歌API密钥连接字符串最频繁。 

phproogle::drawMap() phproogle::drawMap()

此方法返回的JavaScript制作完成的地图本身.

apiKey = is_null($apiKey) ? '' : $apiKey;
        /*** set the map types ***/
        $this->setGoogleMapTypes();
    }
    /*
     *
     * @setter
     *
     * @access public
     *
    */
    public function __set($name, $value) {
        switch ($name) {
            case 'apiKey':
                if (!is_string($value)) {
                    throw new Exception($name, $value, 'string');
                }
                $this->$name = $value;
                break;
            case 'mapZoom':
                if (filter_var($value, FILTER_VALIDATE_INT, array(
                    "options" => array(
                        "min_range" => 0,
                        "max_range" => 19
                    )
                )) == false) {
                    throw new Exception(" $name is out of range");
                }
                $this->$name = $value;
                break;
            case 'mapWidth':
                if (filter_var($value, FILTER_VALIDATE_INT, array(
                    "options" => array(
                        "min_range" => 100,
                        "max_range" => 900
                    )
                )) == false) {
                    throw new Exception(" $name is out of range for");
                }
                $this->$name = $value;
                break;
            case 'mapHeight':
                if (filter_var($value, FILTER_VALIDATE_INT, array(
                    "options" => array(
                        "min_range" => 100,
                        "max_range" => 900
                    )
                )) == false) {
                    throw new Exception(" $name is out of range for");
                }
                $this->$name = $value;
                break;
            case 'mapType':
                if (!array_key_exists($value, $this->googleMapTypes)) {
                    throw new Exception(" $name is not a valid map type");
                }
                $this->$name = $value;
                break;
            case 'mapDivID':
                if (!is_string($value)) {
                    throw new Exception(" $name is not a valid ID");
                }
                $this->$name = $value;
                break;
            case 'mapCenter':
                if (!is_array($value)) {
                    throw new Exception(" $name is not a valid array");
                }
                $this->$name = $value;
                break;
            default:
                throw new Exception("Invalid Parameter $name ");
        }
    }
    /*
     *
     * @getter
     *
     * @access public
     *
    */
    public function __get($name) {
        switch ($name) {
            case 'apiKey':
                return $this->apiKey;
                break;
            case 'mapZoom':
                return $this->mapZoom;
                break;
            case 'mapWidth':
                return $this->mapWidth;
                break;
            case 'mapHeight':
                return $this->mapHeight;
                break;
            case 'mapType':
                return $this->mapType;
                break;
            case 'mapDivID':
                return $this->mapDivID;
                break;
            case 'mapCenter';
            return $this->mapCenter;
            break;
    }
    /*** if we are here, throw an excepton ***/
    throw new Exception(" $name is invalid");
}
/*
 *
 * @isset
 *
 * @access public
 *
*/
public function __isset($name) {
    switch ($name) {
        case 'apiKey':
            $this->apiKey = $name;
            break;
        case 'mapZoom':
            $this->mapZoom = $name;
            break;
        case 'mapWidth':
            $this->mapWidth = $name;
            break;
        case 'mapHeight':
            $this->mapHeight = $name;
            break;
        case 'mapType':
            $this->mapType = $name;
            break;
        case 'mapDivID':
            $this->mapDivID = $name;
            break;
        case 'mapCenter';
        $this->mapCenter = $name;
        break;
    default:
        return false;
}
}
/*
 *
 * @Set the map types
 *
 * @access private
 *
 * @return void
 *
*/
private function setGoogleMapTypes() {
    $this->googleMapTypes = array(
        'physical' => 'G_PHYSICAL_MAP',
        'normal' => 'G_NORMAL_MAP',
        'satellite' => 'G_SATELLITE_MAP',
        'hybrid' => 'G_HYBRID_MAP'
    );
}
/*
 *
 * @add to the array of google maps controls
 *
 * @access public
 *
 * @return void
 *
*/
public function addGoogleMapControl($control) {
    $n = sizeof($this->googleMapControls);
    $this->googleMapControls[] = $control;
}
/*
 *
 * @get pinpoint marker by address
 *
 * @access public
 *
 * @param string $address
 *
 * @param string $html
 *
 * @return void
 *
*/
public function addMarkerAddress($address, $html) {
    $s = sizeof($this->markerAddresses);
    $this->markerAddresses[$s]['address'] = $address;
    $this->markerAddresses[$s]['html'] = $html;
}
/*
 *
 * @get pinpoint mark by latitude or longitude
 *
 * @access public
 *
 * @param string $lat
 *
 * @param string $long
 *
 * @param string $html
 *
 * @return void
 *
*/
public function addMarker($lat, $long, $html) {
    $pointer = sizeof($this->markerPoints);
    $this->markerPoints[$pointer]['lat'] = $lat;
    $this->markerPoints[$pointer]['long'] = $long;
    $this->markerPoints[$pointer]['html'] = $html;
}
/*
 *
 * @The javascript for google to connect
 *
 * @access public
 *
 * @return string
 *
*/
public function googleJS() {
    return '' . " ";
}
private function noJavascript() {
    return '';
}
public function drawMap() {
    $js = '
'; $js.= $this->noJavascript(); $js.= ' '; return $js; } } /*** end of class ***/ try { /*** a new phproogle instance ***/ $map = new phproogleMap(); /*** the google api key ***/ $map->apiKey = 'YOUR_GOOGLE_API_KEY'; /*** zoom is 0 - 19 ***/ $map->mapZoom = 14; /*** the map width ***/ $map->mapWidth = 350; /*** the map height ***/ $map->mapHeight = 300; /*** set the map type ***/ $map->mapType = 'normal'; /*** set the map center ***/ $map->mapCenter = array(-33.862828, 151.216974 ); /*** add some markers with latitude and longitude ***/ $map->addMarker(-33.858362, 151.214876, '

Sydney Opera House

For those with culture

'); $map->addMarker(-33.862828, 151.216974, '

Royal Botanic Gardens

A link here'); /*** add some controls ***/ $map->addGoogleMapControl('GMapTypeControl'); $map->addGoogleMapControl('GSmallMapControl'); $map->addGoogleMapControl('GOverviewMapControl'); /*** add some marker addresses ***/ $map->addMarkerAddress('2 Pitt St Sydney NSW Australia', '

Head Office

'); $map->addMarkerAddress('122 Pitt St Sydney NSW Australia', '

The Factory

'); /*** set the map div id ***/ $map->mapDivID = 'map'; } catch(Exception $e) { echo $e->getMessage(); } ?> googleJS (); drawMap ();


教程链接:

随意转载~但请保留教程地址★

PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载

相关标签:

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

通义千问
通义千问

阿里巴巴推出的全能AI助手

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
AO3官网入口与中文阅读设置 AO3网页版使用与访问
AO3官网入口与中文阅读设置 AO3网页版使用与访问

本专题围绕 Archive of Our Own(AO3)官网入口展开,系统整理 AO3 最新可用官网地址、网页版访问方式、正确打开链接的方法,并详细讲解 AO3 中文界面设置、阅读语言切换及基础使用流程,帮助用户稳定访问 AO3 官网,高效完成中文阅读与作品浏览。

35

2026.02.02

主流快递单号查询入口 实时物流进度一站式追踪专题
主流快递单号查询入口 实时物流进度一站式追踪专题

本专题聚合极兔快递、京东快递、中通快递、圆通快递、韵达快递等主流物流平台的单号查询与运单追踪内容,重点解决单号查询、手机号查物流、官网入口直达、包裹进度实时追踪等高频问题,帮助用户快速获取最新物流状态,提升查件效率与使用体验。

7

2026.02.02

Golang WebAssembly(WASM)开发入门
Golang WebAssembly(WASM)开发入门

本专题系统讲解 Golang 在 WebAssembly(WASM)开发中的实践方法,涵盖 WASM 基础原理、Go 编译到 WASM 的流程、与 JavaScript 的交互方式、性能与体积优化,以及典型应用场景(如前端计算、跨平台模块)。帮助开发者掌握 Go 在新一代 Web 技术栈中的应用能力。

4

2026.02.02

PHP Swoole 高性能服务开发
PHP Swoole 高性能服务开发

本专题聚焦 PHP Swoole 扩展在高性能服务端开发中的应用,系统讲解协程模型、异步IO、TCP/HTTP/WebSocket服务器、进程与任务管理、常驻内存架构设计。通过实战案例,帮助开发者掌握 使用 PHP 构建高并发、低延迟服务端应用的工程化能力。

3

2026.02.02

Java JNI 与本地代码交互实战
Java JNI 与本地代码交互实战

本专题系统讲解 Java 通过 JNI 调用 C/C++ 本地代码的核心机制,涵盖 JNI 基本原理、数据类型映射、内存管理、异常处理、性能优化策略以及典型应用场景(如高性能计算、底层库封装)。通过实战示例,帮助开发者掌握 Java 与本地代码混合开发的完整流程。

2

2026.02.02

go语言 注释编码
go语言 注释编码

本专题整合了go语言注释、注释规范等等内容,阅读专题下面的文章了解更多详细内容。

62

2026.01.31

go语言 math包
go语言 math包

本专题整合了go语言math包相关内容,阅读专题下面的文章了解更多详细内容。

55

2026.01.31

go语言输入函数
go语言输入函数

本专题整合了go语言输入相关教程内容,阅读专题下面的文章了解更多详细内容。

27

2026.01.31

golang 循环遍历
golang 循环遍历

本专题整合了golang循环遍历相关教程,阅读专题下面的文章了解更多详细内容。

33

2026.01.31

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
PHP课程
PHP课程

共137课时 | 10.8万人学习

JavaScript ES5基础线上课程教学
JavaScript ES5基础线上课程教学

共6课时 | 11.2万人学习

PHP新手语法线上课程教学
PHP新手语法线上课程教学

共13课时 | 0.9万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号