<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html > <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>GoogleMap.jsp</title> <link rel="stylesheet" href="../Script/theme/default/style.css" type="text/css"> <link rel="stylesheet" href="../Style/style.css" type="text/css"> <style type="text/css"> #mymap { width: 800px; height: 400px; border:1px solid gray; } </style> <script type="text/javascript" src="../Script/jquery.js"></script> <script type="text/javascript" src="../Script/lib/OpenLayers.js"></script> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> <script type="text/javascript"> function init(){ var map = new OpenLayers.Map('mymap'); //创建google Map图层对象 var googleLayer = new OpenLayers.Layer.Google("google"); var styleMap = new OpenLayers.StyleMap({ 'default': new OpenLayers.Style({ strokeColor: "#333333", strokeWidth: 1.2, strokeOpacity: 1 }), 'select': new OpenLayers.Style({ fillColor: "red", strokeWidth: 10, pointRadius: 30 })/* , 'temporary': new OpenLayers.Style({ strokeColor: "yellow" }) */ }); // 添加图层 map.addLayers([googleLayer]); var switchControl = new OpenLayers.Control.LayerSwitcher(); map.addControls([switchControl, new OpenLayers.Control.MousePosition()]); map.addControl(new OpenLayers.Control.Zoom({"zoomInText":'大', "zoomOutText":'小'})); map.zoomToMaxExtent(); var ll = null; var wind = null; map.events.register('click', this, function(event) { if (wind != null) { wind.close(); } /* if (map.popups.length > 0) { for (var i = map.popups.length - 1; i >= 0; --i) { if (map.popups[i] != null) { map.removePopup(map.popups[i]); } } } */ ll = map.getLonLatFromPixel(event.xy).transform( map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326") ); /* map.setCenter(ll.transform( new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject() )); */ // popup = new OpenLayers.Popup("chicken", // ll.transform( // new OpenLayers.Projection("EPSG:4326"), // map.getProjectionObject() // ), // new OpenLayers.Size(200,100), // "example popup", // true); /* popup = new OpenLayers.Popup.FramedCloud("chicken", ll.transform( new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject() ), new OpenLayers.Size(200,100), "example popup", null, true); popup.panMapIfOutOfView = true; map.addPopup(popup); */ wind = new google.maps.InfoWindow({ content:'<div style="height:100px;width:200px;">aaa<br>aaa</div>', maxWidth: 400, position:new google.maps.LatLng(ll.lat,ll.lon), pixelOffset: new google.maps.Size(0,0), zIndex: 1000010, disableAutoPan: true }); wind.open(OpenLayers.Layer.Google.cache['OpenLayers_Map_2'].mapObject); }); // 将地图中心点设置为西安市,有外部到地图需要转换,Google地图投影为EPSG:900913 // 从地图到外部也是需要转换的,刚好是反的,每种地图的投影是不一样的 map.setCenter(new OpenLayers.LonLat( 108.88769544660661, 34.33617899255311 ).transform( new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject() )); /* if (map != OpenLayers.Layer.Google.v3) {// var aa = OpenLayers.Layer.Google.cache['OpenLayers_Map_2'].mapObject; console.log(aa); } */ } </script> </head> <body onload="init();">
<div id="mymap" class="smallmap"></div> <div id="sanjiao" style="position: absolute;display: none;width: 20px;height: 30px;background-color: red;"></div> </body> </html>
GoogleMaps-API 写道
https://developers.google.com/maps/documentation/javascript/3.exp/reference?hl=zh-cn#InfoWindow
相关推荐
openlayers 利用google maps的卫星地图 29 openLayers集成google map ,点标注错位 30 openlayers可以做出谷歌效果的地图吗? 31 用OpenLayers API和类来画点、线、面 32 OGC标准术语介绍WMS、WFS、WCS 35 如何控制...
关于openlayers开发的一个中文手册,供大家学习。
openlayers加载google微信影像,完整demo,可直接使用浏览器运行。
openlayers中文文档,openlayers中文文档api
增强地图体验,并为其用户和客户提供在不放弃情况下在其项目中使用Google Maps的能力。 调用API ... < link rel =" stylesheet " href =" ...
基于Openlayers和GoogleMap技术的边检Web地理信息系统研究.pdf
OpenLayers 支持的地图来源包括Google Maps、Yahoo! Map、微软Virtual Earth 等。用户还可以用简单的图片地图作为背景图,与其他的图层在OpenLayers 中进行叠加。除此之外,OpenLayers 支持Open GIS 协会制定的WMS...
OpenLayers中文学习文档,原始文档是.md格式的转换成Html后转换成了chm格式,感谢原文作者。
OpenLayers地图加入google图层 OpenLayers google layer 自己可以用google账号登录申请特定域名的地图key.
openlayers中文文档,openlayers中文文档api
侧边栏v2 用于映射诸如或库的响应式... OpenLayers 2 examples/ol2.html (预览)上的示例代码 谷歌地图 examples/gmaps.html (预览)上的示例代码 执照 sidebar-v2是免费软件,可以根据MIT许可证重新分发。
openLayers-API中文,全,我找了好久,提供给大家
OpenLayers 支持的地图来源包括Google Maps、Yahoo、 Map、微软Virtual Earth 等,用户还可以用简单的图片地图作为背景图,与其他的图层在OpenLayers 中进行叠加,在这一方面OpenLayers提供了非常多的选择。...
Openlayers是纯javascript开发的一套能够提供地图操作的库。其中引用了Prototype.js和Rico...Openlayers与Google Maps和Visual Earth类似,都能够在现有的web应用中动态加入一些地图服务,使得现有的web应用更加直观。
ol3-google-maps, OpenLayers 谷歌地图 集成 OL3-Google-Maps OpenLayers - 谷歌地图 集成库。 使用创建一个地图,使用 谷歌地图 作为基础地图,更多的信息。特性同步:层( Google,矢量)矢量特征( 样式,几何图形)...
OpenLayers3加载谷歌地图,加载谷歌地图显示,实现效果很好,放大比例尺也能看得清楚。文章链接:https://blog.csdn.net/Gary_888/article/details/89914290
一个Vue与Openlayers结合的应用示例,以组件的方式在Vue中使用openlayers地图,以及可以进行简单的地图配置
ol openlayers 中文 文档 翻译 最新编译、不全、差评的别下、嫌分高别下
openLayers-API中文版