<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script
src="http://ditu.google.com/maps?file=api&v=2&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA&hl=zh-CN"
type="text/javascript"></script>
<script type="text/javascript">
var cenx = 39.990168;
var ceny = 116.295304;
var stzoom=13;
var map;
function MarkerClusterer(map, opt_markers, opt_opts) {
// private members
var clusters_ = [];
var map_ = map;
var maxZoom_ = null;
var me_ = this;
var gridSize_ = 60;
var sizes = [53, 56, 66, 78, 90];
var styles_ = [];
var leftMarkers_ = [];
var mcfn_ = null;
var i = 0;
for (i = 1; i <= 5; ++i) {
styles_.push({
'url': "images/m" + i + ".png",
'height': sizes[i - 1],
'width': sizes[i - 1]
});
}
if (typeof opt_opts === "object" && opt_opts !== null) {
if (typeof opt_opts.gridSize === "number" && opt_opts.gridSize > 0) {
gridSize_ = opt_opts.gridSize;
}
if (typeof opt_opts.maxZoom === "number") {
maxZoom_ = opt_opts.maxZoom;
}
if (typeof opt_opts.styles === "object" && opt_opts.styles !== null && opt_opts.styles.length !== 0) {
styles_ = opt_opts.styles;
}
}
function addLeftMarkers_() {
if (leftMarkers_.length === 0) {
return;
}
var leftMarkers = [];
for (i = 0; i < leftMarkers_.length; ++i) {
me_.addMarker(leftMarkers_[i], true, null, null, true);
}
leftMarkers_ = leftMarkers;
}
this.getStyles_ = function () {
return styles_;
};
this.clearMarkers = function () {
for (var i = 0; i < clusters_.length; ++i) {
if (typeof clusters_[i] !== "undefined" && clusters_[i] !== null) {
clusters_[i].clearMarkers();
}
}
clusters_ = [];
leftMarkers_ = [];
GEvent.removeListener(mcfn_);
};
function isMarkerInViewport_(marker) {
return map_.getBounds().containsLatLng(marker.getLatLng());
}
function reAddMarkers_(markers) {
var len = markers.length;
var clusters = [];
for (var i = len - 1; i >= 0; --i) {
me_.addMarker(markers[i].marker, true, markers[i].isAdded, clusters, true);
}
addLeftMarkers_();
}
this.addMarker = function (marker, opt_isNodraw, opt_isAdded, opt_clusters, opt_isNoCheck) {
if (opt_isNoCheck !== true) {
if (!isMarkerInViewport_(marker)) {
leftMarkers_.push(marker);
return;
}
}
var isAdded = opt_isAdded;
var clusters = opt_clusters;
var pos = map_.fromLatLngToDivPixel(marker.getLatLng());
if (typeof isAdded !== "boolean") {
isAdded = false;
}
if (typeof clusters !== "object" || clusters === null) {
clusters = clusters_;
}
var length = clusters.length;
var cluster = null;
for (var i = length - 1; i >= 0; i--) {
cluster = clusters[i];
var center = cluster.getCenter();
if (center === null) {
continue;
}
center = map_.fromLatLngToDivPixel(center);
// Found a cluster which contains the marker.
if (pos.x >= center.x - gridSize_ && pos.x <= center.x + gridSize_ &&
pos.y >= center.y - gridSize_ && pos.y <= center.y + gridSize_) {
cluster.addMarker({
'isAdded': isAdded,
'marker': marker
});
if (!opt_isNodraw) {
cluster.redraw_();
}
return;
}
}
// No cluster contain the marker, create a new cluster.
cluster = new Cluster(this, map);
cluster.addMarker({
'isAdded': isAdded,
'marker': marker
});
if (!opt_isNodraw) {
cluster.redraw_();
}
// Add this cluster both in clusters provided and clusters_
clusters.push(cluster);
if (clusters !== clusters_) {
clusters_.push(cluster);
}
};
this.removeMarker = function (marker) {
for (var i = 0; i < clusters_.length; ++i) {
if (clusters_[i].remove(marker)) {
clusters_[i].redraw_();
return;
}
}
};
this.redraw_ = function () {
var clusters = this.getClustersInViewport_();
for (var i = 0; i < clusters.length; ++i) {
clusters[i].redraw_(true);
}
};
this.getClustersInViewport_ = function () {
var clusters = [];
var curBounds = map_.getBounds();
for (var i = 0; i < clusters_.length; i ++) {
if (clusters_[i].isInBounds(curBounds)) {
clusters.push(clusters_[i]);
}
}
return clusters;
};
/**
* Get max zoom level.
* @private
* @return {Number}
*/
this.getMaxZoom_ = function () {
return maxZoom_;
};
/**
* Get map object.
* @private
* @return {GMap2}
*/
this.getMap_ = function () {
return map_;
};
/**
* Get grid size
* @private
* @return {Number}
*/
this.getGridSize_ = function () {
return gridSize_;
};
/**
* Get total number of markers.
* @return {Number}
*/
this.getTotalMarkers = function () {
var result = 0;
for (var i = 0; i < clusters_.length; ++i) {
result += clusters_[i].getTotalMarkers();
}
return result;
};
/**
* Get total number of clusters.
* @return {int}
*/
this.getTotalClusters = function () {
return clusters_.length;
};
/**
* Collect all markers of clusters in viewport and regroup them.
*/
this.resetViewport = function () {
var clusters = this.getClustersInViewport_();
var tmpMarkers = [];
var removed = 0;
for (var i = 0; i < clusters.length; ++i) {
var cluster = clusters[i];
var oldZoom = cluster.getCurrentZoom();
if (oldZoom === null) {
continue;
}
var curZoom = map_.getZoom();
if (curZoom !== oldZoom) {
// If the cluster zoom level changed then destroy the cluster
// and collect its markers.
var mks = cluster.getMarkers();
for (var j = 0; j < mks.length; ++j) {
var newMarker = {
'isAdded': false,
'marker': mks[j].marker
};
tmpMarkers.push(newMarker);
}
cluster.clearMarkers();
removed++;
for (j = 0; j < clusters_.length; ++j) {
if (cluster === clusters_[j]) {
clusters_.splice(j, 1);
}
}
}
}
// Add the markers collected into marker cluster to reset
reAddMarkers_(tmpMarkers);
this.redraw_();
};
this.addMarkers = function (markers) {
for (var i = 0; i < markers.length; ++i) {
this.addMarker(markers[i], true);
}
this.redraw_();
};
// initialize
if (typeof opt_markers === "object" && opt_markers !== null) {
this.addMarkers(opt_markers);
}
// when map move end, regroup.
mcfn_ = GEvent.addListener(map_, "moveend", function () {
me_.resetViewport();
});
}
function Cluster(markerClusterer) {
var center_ = null;
var markers_ = [];
var markerClusterer_ = markerClusterer;
var map_ = markerClusterer.getMap_();
var clusterMarker_ = null;
var zoom_ = map_.getZoom();
this.getMarkers = function () {
return markers_;
没有合适的资源?快使用搜索试试~ 我知道了~
ch8.rar_网页
共63个文件
svn-base:28个
png:16个
html:14个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 38 浏览量
2022-09-21
08:07:30
上传
评论
收藏 225KB RAR 举报
温馨提示
功能全面的API组件,用于网页的开发,方面用户
资源推荐
资源详情
资源评论
收起资源包目录
ch8.rar (63个子文件)
ch8
8.2.4_GPolyline_rule.html 2KB
images
m4.png 4KB
m3.png 4KB
m5.png 4KB
heart30.png 1KB
conv50.png 2KB
people35.png 1KB
m2.png 3KB
heart40.png 2KB
tile_crosshairs.png 203B
us_counties.png 128KB
heart50.png 3KB
pgreen.gif 954B
pred.gif 218B
m1.png 3KB
people45.png 2KB
people55.png 3KB
conv30.png 1KB
conv40.png 1KB
.svn
all-wcprops 2KB
prop-base
heart30.png.svn-base 37B
heart50.png.svn-base 37B
heart40.png.svn-base 37B
m4.png.svn-base 37B
people55.png.svn-base 37B
m2.png.svn-base 37B
conv30.png.svn-base 37B
conv50.png.svn-base 37B
m3.png.svn-base 37B
conv40.png.svn-base 37B
people35.png.svn-base 37B
m1.png.svn-base 37B
m5.png.svn-base 37B
people45.png.svn-base 37B
props
tmp
prop-base
props
text-base
text-base
heart30.png.svn-base 1KB
heart50.png.svn-base 3KB
heart40.png.svn-base 2KB
m4.png.svn-base 4KB
people55.png.svn-base 3KB
m2.png.svn-base 3KB
conv30.png.svn-base 1KB
conv50.png.svn-base 2KB
m3.png.svn-base 4KB
conv40.png.svn-base 1KB
people35.png.svn-base 1KB
m1.png.svn-base 3KB
m5.png.svn-base 4KB
people45.png.svn-base 2KB
entries 2KB
format 2B
8.3.3_GMapType.html 4KB
8.2.2_GPolyline_editable.html 2KB
8.1.5_GMarker_optimize.html 17KB
8.1.1_GMarker_simple.html 2KB
8.1.3_GMarker_windowinfo.html 4KB
8.1.2_GMarker_GIcon.html 5KB
8.1.4_GMarker_overwrite.html 5KB
8.2.1_GPolyline_simple.html 2KB
8.2.6_GPolyline_encoding_adance.html 6KB
8.3.2_GTileLayer.html 2KB
8.2.3_GPolyline_vertex.html 3KB
8.2.5_GPolyline_encoding.html 2KB
8.3.1_GGroundOverlay.html 2KB
共 63 条
- 1
资源评论
邓凌佳
- 粉丝: 66
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功