jQuery谷歌地图插件maplace.js

所属分类:媒体-地图

 67997  329  查看评论 (10)
分享到微信朋友圈
X
jQuery谷歌地图插件maplace.js ie兼容6

非常小的谷歌地图jQuery插件

Maplace.js帮助你嵌入你的网站,谷歌地图,快速创建标记和控制菜单在地图上的位置。

需要jQuery的谷歌地图API v3的在您的网页。


特点


直接实现简单的选项

可以运行所需的许多地图

标记和自定义图标,缩放级别和自定义控件菜单

支持方向,多边形,折线,融合表和风格的地图

作品在所有主要浏览器,包括IE6(这个网站没有这么多)


使用步骤

下载最新版本的Maplace.js,包括谷歌地图API v3和jQuery一起。

<script src="http://maps.google.com/maps/api/js?sensor=false&libraries=geometry&v=3.7">
</script>
<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<script src="maplace.min.js"></script>

HTML

现在你可以创建地图。

<script type="text/javascript">
$(function() {
	new Maplace({
		locations: [{...}, {...}],
		controls_on_map: false
	}).Load();
});
</script>

如果你想为中心的单一位置的地图上没有任何标记,你有两种选择:

new Maplace({
	show_markers: false,
	locations: [{
		lat: 45.9, 
		lon: 10.9,
		zoom: 8
	}]
}).Load(); 

//or

new Maplace({
	map_options: {
		set_center: [45.9, 10.9],
		zoom: 8
	}
}).Load()

添加一个新的菜单类型

var html_checks = {
		//required: called by Maplace.js to activate the current voice on menu
		activateCurrent: function(index) {
				this.html_element.find("input[value='" + index + "']").attr('checked', true);
		},
		//required: called by Maplace.js to get the html of the menu
		getHtml: function() {
				var self = this,
						html = '';

				//if more than one location
				if(this.ln > 1) {
						html += '<div class="checkbox controls ' + this.o.controls_cssclass + '">';

						//check "view all" link
						//use ShowOnMenu(index) to know if a location has to appear on menu
						if(this.ShowOnMenu(this.view_all_key)) {
								html += '<label><input type="radio" name="gmap" value="'
										 + this.view_all_key + '"/>' + this.o.view_all_text + '</label>';
						}

						//iterate the locations
						for (var a = 0; a < this.ln; a++) {
								if(this.ShowOnMenu(a)) 
									html += '<label><input type="radio" name="gmap" value="' + (a+1) + '"/>' 
											 + (this.o.locations[a].title || ('#' + (a+1))) + '</label>';
						}
						html += '</div>';
				}

				this.html_element = $('<div class="wrap_controls"></div>').append(html);

				//event on change
				//use ViewOnMap(index) to trigger the marker on map
				this.html_element.find('input[type=radio]').bind('change', function() {
						self.ViewOnMap(this.value); 
				});
				
				return this.html_element;
		}
};
//new Maplace object
var maplace = new Maplace();

//add the new menu with the method AddControl(name, function)
maplace.AddControl('checks', html_checks);

//load the map
maplace.Load({
	controls_type: 'checks',
	locations: [{...}, {...}]
});


相关插件-地图

jQuery中国省份地图三级联动

jQuery中国省份地图三级联动代码基于jquery制作,省市区三级联动代码,下拉框中选择中国省份,在地图上面高亮显示。
  地图
 23802  218

jQuery小地图预览插件(预览完整的网页)

minimap是一个可以快速预览完整的网页或其与灵活的定位和导航支持DOM元素。
  地图
 36156  385

百度地图路书 (轨迹回放功能)

轨迹回放,边走边出路线边出点标记
  地图
 73759  356

百度地图回放路线

实现路线行驶回放等功能
  地图
 31104  333

讨论这个项目(10)回答他人问题或分享插件使用方法奖励jQ币 评论用户自律公约

    愚也愉 づ 0
    2018/4/12 14:18:51
    怎么定位当前位置呢
    回复
    刘顽富 0
    2017/8/8 14:10:58
    非常好,广告好需要用到,哈哈非常强大 回复
    幸福的拥抱(七年前) 0
    2017/7/18 18:11:21
    kwongd 0
    2016/5/10 13:05:39
    在天朝,真无奈 回复
    Roc-J 0
    2016/5/7 17:05:53
    这个我在电脑测试运行不通过,不成功。 回复
    cwc1305206287 0
    2015/10/9 11:10:02

    现在电脑连不上谷歌,好像用不了诶

    回复
    Angela雨香 0
    2015/8/21 20:08:58

    挺不错的,方法比较多,可惜就是必须上谷歌才行

    回复
    ? 0
    2015/8/4 13:08:11

    这个还好吧。 可以参考一下

    回复
    成长の日 0
    2015/7/25 21:07:23
    不错,很详细。 回复
    绝望了 0
    2014/12/30 13:27:52
😃
  • 😀
  • 😉
  • 😥
  • 😵
  • 😫
  • 😘
  • 😡
  • 👍
  • 🌹
  • 👏
  • 🍺
  • 🍉
  • 🌙
  • 💖
  • 💔
😃
  • 😀
  • 😉
  • 😥
  • 😵
  • 😫
  • 😘
  • 😡
  • 👍
  • 🌹
  • 👏
  • 🍺
  • 🍉
  • 🌙
  • 💖
  • 💔
取消回复