热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

phpgoogleapi接口程序

常用的google地图开发参数phproogle::apiKey.这是谷歌的用户API密钥,这也可以设置使用时,一个新的实例是instanciated构造.phproogle::addGoogl...
常用的google地图开发参数

phproogle::apiKey

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

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

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

* 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()

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

顾名思义,这将设置p的宽度该地图居住于默认宽度为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 p id ***/ $map->mapDivID = 'map'; } catch(Exception $e) { echo $e->getMessage(); } ?> googleJS (); drawMap ();


教程链接:

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

推荐阅读
  • Java验证码——kaptcha的使用配置及样式
    本文介绍了如何使用kaptcha库来实现Java验证码的配置和样式设置,包括pom.xml的依赖配置和web.xml中servlet的配置。 ... [详细]
  • 微软头条实习生分享深度学习自学指南
    本文介绍了一位微软头条实习生自学深度学习的经验分享,包括学习资源推荐、重要基础知识的学习要点等。作者强调了学好Python和数学基础的重要性,并提供了一些建议。 ... [详细]
  • 本文讨论了Alink回归预测的不完善问题,指出目前主要针对Python做案例,对其他语言支持不足。同时介绍了pom.xml文件的基本结构和使用方法,以及Maven的相关知识。最后,对Alink回归预测的未来发展提出了期待。 ... [详细]
  • 在说Hibernate映射前,我们先来了解下对象关系映射ORM。ORM的实现思想就是将关系数据库中表的数据映射成对象,以对象的形式展现。这样开发人员就可以把对数据库的操作转化为对 ... [详细]
  • 本文介绍了在SpringBoot中集成thymeleaf前端模版的配置步骤,包括在application.properties配置文件中添加thymeleaf的配置信息,引入thymeleaf的jar包,以及创建PageController并添加index方法。 ... [详细]
  • 知识图谱——机器大脑中的知识库
    本文介绍了知识图谱在机器大脑中的应用,以及搜索引擎在知识图谱方面的发展。以谷歌知识图谱为例,说明了知识图谱的智能化特点。通过搜索引擎用户可以获取更加智能化的答案,如搜索关键词"Marie Curie",会得到居里夫人的详细信息以及与之相关的历史人物。知识图谱的出现引起了搜索引擎行业的变革,不仅美国的微软必应,中国的百度、搜狗等搜索引擎公司也纷纷推出了自己的知识图谱。 ... [详细]
  • 推荐系统遇上深度学习(十七)详解推荐系统中的常用评测指标
    原创:石晓文小小挖掘机2018-06-18笔者是一个痴迷于挖掘数据中的价值的学习人,希望在平日的工作学习中,挖掘数据的价值, ... [详细]
  • 本文介绍了Linux系统中正则表达式的基础知识,包括正则表达式的简介、字符分类、普通字符和元字符的区别,以及在学习过程中需要注意的事项。同时提醒读者要注意正则表达式与通配符的区别,并给出了使用正则表达式时的一些建议。本文适合初学者了解Linux系统中的正则表达式,并提供了学习的参考资料。 ... [详细]
  • 本文介绍了使用cacti监控mssql 2005运行资源情况的操作步骤,包括安装必要的工具和驱动,测试mssql的连接,配置监控脚本等。通过php连接mssql来获取SQL 2005性能计算器的值,实现对mssql的监控。详细的操作步骤和代码请参考附件。 ... [详细]
  • Javascript中带有加号 - 减号(±)的极坐标曲线方程 - Polar curve equation with plus-minus sign (±) in Javascript
    IamtryingtodrawpolarcurvesonHTMLcanvasusingJavascript.WhatshouldIdowhenIwanttoco ... [详细]
  • 前言对于从事技术的人员来说ajax是这好东西,都会使用,而且乐于使用。但对于新手,开发一个ajax实例,还有是难度的,必竟对于他们这是新东西。leo开发一个简单的ajax实例,用的是 ... [详细]
  • 表单提交前的最后验证:通常在表单提交前,我们必须确认用户是否都把必须填选的做了,如果没有,就不能被提交到服务器,这里我们用到表单的formname.submit()看演示,其实这个对于我们修炼道 ... [详细]
  • Java序列化对象传给PHP的方法及原理解析
    本文介绍了Java序列化对象传给PHP的方法及原理,包括Java对象传递的方式、序列化的方式、PHP中的序列化用法介绍、Java是否能反序列化PHP的数据、Java序列化的原理以及解决Java序列化中的问题。同时还解释了序列化的概念和作用,以及代码执行序列化所需要的权限。最后指出,序列化会将对象实例的所有字段都进行序列化,使得数据能够被表示为实例的序列化数据,但只有能够解释该格式的代码才能够确定数据的内容。 ... [详细]
  • HDU 2372 El Dorado(DP)的最长上升子序列长度求解方法
    本文介绍了解决HDU 2372 El Dorado问题的一种动态规划方法,通过循环k的方式求解最长上升子序列的长度。具体实现过程包括初始化dp数组、读取数列、计算最长上升子序列长度等步骤。 ... [详细]
  • Android中高级面试必知必会,积累总结
    本文介绍了Android中高级面试的必知必会内容,并总结了相关经验。文章指出,如今的Android市场对开发人员的要求更高,需要更专业的人才。同时,文章还给出了针对Android岗位的职责和要求,并提供了简历突出的建议。 ... [详细]
author-avatar
挠挠扣扣笑嘻嘻
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有