html 5获取GPS位置,Google地图显示

场景:

JQuery Mobile

代码片段:

	<script type="text/javascript">
$('#mylocation').live('pageshow', function () {
if (navigator.onLine) {
$("#mylocation_status").text('网络连接正常');
} else {
$("#mylocation_status").text('没有网络连接');
} if(navigator.geolocation) {
$("#mylocation_status").text('GPS定位中。。。'); navigator.geolocation.getCurrentPosition(function(position) {
$("#mylocation_status").text('GPS定位完成,' + position.coords.latitude + ',' + position.coords.longitude);
htmlString = "<img src='http://maps.googleapis.com/maps/api/staticmap?";
htmlString = htmlString + "center=" + position.coords.latitude + "," + position.coords.longitude + "&";
htmlString = htmlString + "zoom=15&size=290x360&maptype=roadmap&markers=color:red%7Clabel:S%7C" + position.coords.latitude + "," + position.coords.longitude + "&sensor=false'/>";
$("#map_canvas").html(htmlString);
});
}else {
$("#mylocation_status").text('GPS定位失败');
} });
</script>

参考:

Static Maps API V2 Developer Guide  静态图片API key要申请 https://developers.google.com/maps/documentation/staticmaps/#api_key
API说明 https://developers.google.com/maps/documentation/staticmaps/#api_key
测试: NY http://maps.googleapis.com/maps/api/staticmap?center=New+York,NY&zoom=13&size=600x300&key=API_console_key SH http://maps.googleapis.com/maps/api/staticmap?center=Shanghai+Hai,SH&zoom=13&size=600x300&key=AIzaSyBP24UOltpPGbNYDa-sS7YXKEvkxuPHfNs&sensor=false

Mobile Web 应用例子程序   :  Build an Exercise Tracking App: Persistence & Graphing

http://mobile.tutsplus.com/tutorials/phonegap/build-an-exercise-tracking-app-geolocation-tracking/

HTML5显示地图例子的更多相关文章

  1. 基于ECharts 的地图例子

      最近的一个项目要用到显示地图,本来用jq做了一个,但由于客户不满意(确实自己弄的样式效果都不是太理想),于是就上网搜了搜,最后决定基于百度的ECharts来弄地图 本来自己js基础不是很扎实,EC ...

  2. JavaWeb和WebGIS学习笔记(五)——使用OpenLayers显示地图

    系列链接: Java web与web gis学习笔记(一)--Tomcat环境搭建 Java web与web gis学习笔记(二)--百度地图API调用 JavaWeb和WebGIS学习笔记(三)-- ...

  3. Google Maps API显示地图的小示例

    来源:http://www.ido321.com/1089.html 效果(新版Firefox中测试): 代码: <!DOCTYPE> <html> <head> ...

  4. Swift - 使用MapKit显示地图,并在地图上做标记

    通过使用MapKit可以将地图嵌入到视图中,MapKit框架除了可以显示地图,还支持在地图上做标记. 1,通过mapType属性,可以设置地图的显示类型 MKMapType.Standard :标准地 ...

  5. 转载-SharePoint 2010 WebPart与Google地图系列 一:创建显示地图的WebPart

    [原] SharePoint 2010 WebPart与Google地图系列 一:创建显示地图的WebPart 摘要: 作为信息化先驱的产品SharePoint 2010竟然对GIS相关技术支持如此有 ...

  6. openlayers一:显示地图与鼠标地理坐标

    openlayers两个好用的开源JS互动地图库之一,另一个是leaflet. openlayers的特点是是大而全,自身包含绝大多数功能,文档好看. leaflet是小而美,自身小,但支持扩展,好用 ...

  7. 百度地图api通过地址显示地图,白名单

    百度地图api通过地址显示地图,白名单 http://developer.baidu.com/map/jsdemo.htm#i7_1?qq-pf-to=pcqq.c2c---------------- ...

  8. (android 地图实战开发)2 创建MapActivity,根据设备当前位置,显示地图

    (android 地图实战开发)2 创建MapActivity,根据设备当前位置,显示地图 http://www.cnblogs.com/macroxu-1982/archive/2011/09/13 ...

  9. android菜鸟学习笔记30----Android使用百度地图API(一)准备工作及在应用中显示地图

    1.准备工作: 百度地图API是免费开放的,但是需要申请API Key: 1)先注册一个百度开发者帐号 2)进入百度开放服务平台http://developer.baidu.com/ 3)进入LBS云 ...

随机推荐

  1. 完全搞懂傅里叶变换和小波(2)——三个中值定理<转载>

    书接上文,本文章是该系列的第二篇,按照总纲中给出的框架,本节介绍三个中值定理,包括它们的证明及几何意义.这三个中值定理是高等数学中非常基础的部分,如果读者对于高数的内容已经非常了解,大可跳过此部分.当 ...

  2. Sprint第二个冲刺(第五天)

    一.Sprint 计划会议: 容杰龙继续完善昨天的SQLite修改数据操作,待全部操作完善后交给炜杰进行布局规范和整合. 二.Sprint周期:   看板: 燃尽图:

  3. poj 3159 dijkstra 最短路

    Description During the kindergarten days, flymouse was the monitor of his class. Occasionally the he ...

  4. C函数及指针学习2

    1.break  永久终止循环,continue 结束当前循环 2.switch 每个case标签要有唯一值,(且为常量或常量表达式) 不加break 时执行流会贯穿整个case 标签 3 赋值操作符 ...

  5. scala言语基础学习二

    使用yield和函数式编程转化数组 算法案例(移除第一个负数之后的所有负数) 改良高校方案

  6. Mysql存储日期类型用int、timestamp还是datetime?

    通常存储时间用datetime类型,现在很多系统也用int存储时间,它们有什么区别?个人更喜欢使用int这样对于日期计算时比较好哦,下面我们一起来看到底那种会好些. int ().4个字节存储,INT ...

  7. Android 开发 之 Fragment 详解

    本文转载于 : http://blog.csdn.net/shulianghan/article/details/38064191 本博客代码地址 : -- 单一 Fragment 示例 : http ...

  8. bootstrap源码里的function加上了+号

    一般看JQuery插件里的写法是这样的 (function($) { //... })(jQuery); 今天看到bootstrap的javascript组件是这样写的 !function( $ ){ ...

  9. The differences between Java EE components and "standard" Java classes

    https://docs.oracle.com/javaee/7/tutorial/overview003.htm ava EE components are written in the Java ...

  10. python tornado框架使用

    处理方法 t_handler.py from tornado.web import RequestHandler class IndexHandler(RequestHandler): def get ...