google map v3 地址定位器

简介:

好久没写博客了,今天做了一个谷歌地址定位器的小实验,因为是第一次用谷歌地图API,犯了不少小白的问题,记录下来

1、首先是谷歌api的引入,看到官网上一直都是这样写的:


<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 

于是复制粘贴到自己的程序中,可是打开的时候巨慢,地图经常加再不进来,网上百度了一下才发现应该这样写:


<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=zh-CN"></script> 

后面应该跟上地区语言。这个应该是谷歌根据区域不同加载不同的api吧。

2、地址定位器:


geocoder.geocode( { 'address': address,"language":"zh_cn"}, dojo.hitch(this, function(results, status) {  
            if (status == google.maps.GeocoderStatus.OK) {  
                console.log("GeocoderStatus.OK");
                if(results[0]){  
                    var point = results[0].geometry.location;  
                    this.map.setCenter(point);  
                    var marker = new google.maps.Marker({  
                                    position: point,  
                                    map: this.map  
                                    });    
                    //$L.add(marker,"click",function(){  
                    //    $I.add("我在这里").open(map,marker);  
                   // })  
                }  
            } else {  
                alert("Geocode was not successful for the following reason: " + status);  
            }  
        }));

这个没什么难的,就是地址定位器的参数问题,如果你在引用api的时候加上language参数,则无法使用中文地址解析


目录
相关文章
|
4月前
Google Earth Engine(GEE)——从列表中少选所需要的数字不用map函数,还能如何实现?简单方法介绍
Google Earth Engine(GEE)——从列表中少选所需要的数字不用map函数,还能如何实现?简单方法介绍
39 0
|
4月前
|
Android开发
如何在Android真机上检测是否有Google Map add-on
如何在Android真机上检测是否有Google Map add-on
50 3
|
4月前
|
Shell
android2.3.4没有google map的真机上增加google map(原创)
android2.3.4没有google map的真机上增加google map(原创)
43 4
|
4月前
|
分布式计算 Kubernetes 监控
容器服务Kubernetes版产品使用合集之registry.aliyuncs.com/google_containers 镜像仓库的地址是什么
容器服务Kubernetes版,作为阿里云提供的核心服务之一,旨在帮助企业及开发者高效管理和运行Kubernetes集群,实现应用的容器化与微服务化。以下是关于使用这些服务的一些建议和合集,涵盖基本操作、最佳实践、以及一些高级功能的使用方法。
399 0
|
4月前
Google Earth Engine(GEE)——如何建立一个逐日的时序图表chart用map进行遍历
Google Earth Engine(GEE)——如何建立一个逐日的时序图表chart用map进行遍历
43 0
|
11月前
|
数据处理 开发者 Python
Google Earth Engine Map教程书中英双语
Google Earth Engine Map教程书中英双语
315 0
|
前端开发
Google Earth Engine(GEE)——如何加载ee.FeatureCollection中点数据在MAP中
Google Earth Engine(GEE)——如何加载ee.FeatureCollection中点数据在MAP中
589 0
Google Earth Engine(GEE)——如何加载ee.FeatureCollection中点数据在MAP中
|
搜索推荐
Google设置新标签页默认地址
Google设置新标签页默认地址
Google设置新标签页默认地址
《Visualizing the Latent Space of Vector Drawings from the Google QuickDraw Dataset with SketchRNN,PCA and t-SNE》电子版地址
Visualizing the Latent Space of Vector Drawings from the Google QuickDraw Dataset with SketchRNN,PCA and t-SNE
71 0
《Visualizing the Latent Space of Vector Drawings from the Google QuickDraw Dataset with SketchRNN,PCA and t-SNE》电子版地址
|
Ubuntu JavaScript 前端开发
Google Map api国内正常使用该如何配置(2021最新)
Google Map api国内正常使用该如何配置(2021最新)
479 0
Google Map api国内正常使用该如何配置(2021最新)