<body>
<div id="map">
<div id="menu">
<button id="zoom_in">放大</button>
<button id="zoom_out">缩小</button>
<button id="panto">移动到“武汉”</button>
<button id="restore">复位</button>
</div>
</div>
<script>
var map=new ol.Map({
target:'map',
layer:[],
view:new ol.View({
center:[12950000,4860000],
zoom:8,
minZoom:6,
maxZoom:12,
rotation:Math.PI/6//设置旋转角度
})
})
var tileLayer=new ol.layer.Tile({
source:new ol.source.OSM()
});
map.addLayer(tileLayer);
var view=map.getView();
var zoom=view.getZoom();
var center=view.getCenter();
var rotation=view.getRotation();
document.getElementById("zoom_out").onclick=function(){
var view=map.getView();
var zoom=view.getZoom();
view.setZoom(zoom-1);
}
document.getElementById("zoom_in").onclick=function(){
var view=map.getView();
var zoom=view.getZoom();
view.setZoom(zoom+1);
}
document.getElementById("panto").onclick=function(){
var view=map.getView();
var wh=ol.proj.fromLonLat([114.31667,30.51667]);
view.setCenter(wh);
}
document.getElementById("restore").onclick=function(){
view.setZoom(zoom);
view.setCenter(center);
view.setRotation(rotation);
}
</script>
</body>

												

OpenLayers 3 的地图基本操作的更多相关文章

  1. HTML5 网络拓扑图整合 OpenLayers 实现 GIS 地图应用

    在前面<百度地图.ECharts整合HT for Web网络拓扑图应用>我们有介绍百度地图和 HT for Web 的整合,我们今天来谈谈 OpenLayers 和 HT for Web  ...

  2. HT for Web整合OpenLayers实现GIS地图应用

    HT for Web作为逻辑拓扑图形组件自身没有GIS功能,但可以与各种GIS引擎即其客户端组件进行融合,各取所长实现逻辑拓扑和物理拓扑的无缝融合,本章将具体介绍HT for Web与开发免费的Ope ...

  3. OpenLayers 3 之 地图视图(View)

    OpenLayers 3 之 地图视图(View) 初始化一幅地图,必备的三要素之一视图(view),这个对象主要是控制地图与人的交互,如进行缩放,调节分辨率.地图的旋转等控制.也就是说每个 map对 ...

  4. OpenLayers 3 之 地图控件(control)

    OpenLayers 3 之 地图控件(control) 地图控件(control)是指地图上比例尺,缩略图,拉近拉远的按钮,滚动控制条等控件,默认控件有三个,可以禁用. OpenLayers 3 之 ...

  5. openlayers对接百度地图新方法

    上次给大家提供的openlayers对接百度地图有些问题,是因为没有进行分辨率设置,也没有进行相应的平面坐标转换,获取getURL的方法还是没有变化的 getURL: function (bounds ...

  6. openLayers,常见地图实例

    http://openlayers.org/en/master/examples/epsg-4326.html -- 标尺 http://openlayers.org/en/master/exampl ...

  7. openlayers模仿google地图--地图版权随鹰眼关闭打开而改变位置

    额..题目有点长......今天有个群友问我.想实现google地图地图版权随鹰眼关闭状态改变位置的功能.就是这种<ignore_js_op> 打开鹰眼时  地图版权也随着鹰眼位置改变而改 ...

  8. 使TileCache配合OpenLayers,产生地图瓦块的一些资料(转)

    在tilecache.cfg中配置好被切割地图的参数,比如: [mytestmap]layers=3,5,7,8type=WMSurl=http://localhost/arcgis/services ...

  9. 【01】openLayers 第一个地图

    效果: 代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <t ...

随机推荐

  1. Node.js:模块

    概要:本篇博客主要介绍node.js的模块 1.创建模块 在node.js中创建一个模块非常简单,因为一个文件就是一个模块.我们只需要明白如何从其他文件中获取这个模块.Node.js提供了 expor ...

  2. 利用ckeditor 富文本编辑插件静态化网页

    // step5: 生成静态化html FileOutputStream fos = null;            PrintStream printStream = null;          ...

  3. Spring自动扫描

    需要在Springde 配置文件中加入 <context:component-scan base-package="com.annoation"> base-packa ...

  4. Python库 - import matplotlib.pyplot as plt 报错问题

    为了避免各种问题,请使用最新的2.7.13安装文件   1.先设置好环境变量 在path变量中设置好以下路径: C:\Python27\Scripts C:\Python27    2.大部分报错问题 ...

  5. Matlab - 线性方程组求解

    常用函数:det 计算矩阵的行列式的值inv 求矩阵的逆阵rank 求矩阵的秩[V D]=eig(A) 求矩阵A的特征值和特征向量poly 求矩阵的特征多项式rref 用初等变换将矩阵化成行阶梯形nu ...

  6. Java 散知识

    1.final关键字的用法: 1. final关键字修饰一个基本类型的变量时,该变量不能重新赋值,第一次的值为最终的. 2. fianl关键字修饰一个引用类型变量时,该变量不能重新指向新的对象. 3. ...

  7. javascript点击焦点图

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  8. thinkPHP框架学习笔记

    class ZhuantiAction extends Action { public function index() { $name = trim($this->_get('name')); ...

  9. socket通信实例

    ref: http://www.cnblogs.com/xudong-bupt/archive/2013/12/29/3483059.html http://blog.csdn.net/love_ga ...

  10. hibernate的批量更新、批量删除

    hibernate的批处理API:session.createQuery(hql).executeUpdate(),如果有参数则在执行之前设置参数. 批量更新示例: @Test public void ...