每次在地图上放置地图标记时,我都会尝试获取POI的经度和纬度.
这似乎有效,但它没有返回正确的LonLat - 它是一个更大的数字,不是一个lonlat点.
GetLonLatFromPixel是正确的方法吗?
为凌乱的代码提前道歉!
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
#heatmapArea {
position:relative;
float:left;
width:800px;
height:600px;
border:1px dashed black;
}
</style>
</head>
<body>
<div id="main">
<div id="heatmapArea">
</div>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
var map, layer
function init(){
//create new map position :
map = new OpenLayers.Map('heatmapArea');
var layer = new OpenLayers.Layer.OSM();
var fromProjection = new OpenLayers.Projection("EPSG:4326"); // Transform from WGS 1984
var toProjection = new OpenLayers.Projection("EPSG:900913"); // 23834 to Spherical …Run Code Online (Sandbox Code Playgroud)