Skip to content

Instantly share code, notes, and snippets.

@vivian-stars
vivian-stars / gist:9034830a41811bcf832af31a227b222a
Created July 10, 2017 08:08 — forked from aisk/gist:3735854
百度地图坐标与像素互相转换的方法
pixelToPoint = function(point, zoom, center, bounds) {
// 像素到坐标
if (!point) {
return
}
var zoomUnits = getZoomUnits(zoom);
var mercatorLng = center.lng + zoomUnits * (point.x - bounds.width / 2);
var mercatorLat = center.lat - zoomUnits * (point.y - bounds.height / 2);
var mercatorLngLat = {lng: mercatorLng, lat: mercatorLat};
return mercatorToLngLat(mercatorLngLat)