通过不同的条件在谷歌地图上标记?
问题描述:
您能告诉我们如何在Google地图标记的javascript中添加条件吗?什么时候通过查询标记更改参数会在地图上显示为查询(已过滤)?
could you please tell how to add conditions in javascript for Google Map markers? when the parameters changes by query markers appear on map as query(filtered)?
答
您可以将此用作参考目的,因为HTML我在BODY上调用了初始化函数加载事件,所以你应该调用该函数并传递lat,根据你的条件使用和控制事件。
< title>简单标记
html,body,#map-canvas {
身高:100%;
保证金:0px;
填充:0px
}
函数初始化(l1,l2){
var myLatlng = new google.maps.LatLng(l1,l2);
var mapOptions = {
zoom:4,
center :myLatlng
}
var map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);
var marker = new google.maps.Marker({
position:myLatlng,
map:map,
标题:'Hello World!'
});
}
Hi please use this for reference purpose in that HTML i have called initialize function on BODY load event so you should call that function and passing lat,long as per your condition using and control event.
<title>Simple markers
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
function initialize(l1,l2) {
var myLatlng = new google.maps.LatLng(l1,l2);
var mapOptions = {
zoom: 4,
center: myLatlng
}
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: 'Hello World!'
});
}