在我的最后一页,我有两张地图,一张是法国的,一张是巴黎的。如果LAT/LNG在巴黎,标记就在巴黎地图上;如果LNG在巴黎以外,标记就在法国地图上。
到目前为止,我已经完全按照我想做的做了,但是我被infoWindow困住了:(我可以打开它们,但是不能自动关闭它们...我只想同时打开一个infoWindow。
下面是我的代码(只是JS部分):
function CreateMarker(marker, map, infowindow, description)
{
google.maps.event.addListener(marker, 'click');
marker.setMap(map);
}
function initialize(ListeDesPoints) {
var mapidfOptions = {
center: { lat: 48.856614, lng: 2.352222},
zoom: 11
};
var mapfrOptions = {
center: { lat: 46.227638, lng: 2.213749},
zoom: 5
};
var mapidf = new google.maps.Map(document.getElementById('maps-idf'),
mapidfOptions);
var mapfr = new google.maps.Map(document.getElementById('maps-fr'),
mapfrOptions);
var infowindow = new Array();
var marker = new Array();
for (var i = 0; i < ListeDesPoints.length; i++)
{
marker[i] = new google.maps.Marker({
position: new google.maps.LatLng (ListeDesPoints[i]['lat'], ListeDesPoints[i]['lng']),
title: ListeDesPoints[i]['address']
});
var max_lat = 48.9602260;
var min_lat = 48.7451930;
var max_lng = 2.6327379;
var min_lng = 2.0946256;
if(ListeDesPoints[i]['lat'] > max_lat || ListeDesPoints[i]['lat'] < min_lat || ListeDesPoints[i]['lng'] > max_lng || ListeDesPoints[i]['lng'] < min_lng)
{
var map = mapfr;
}
else
{
var map = mapidf;
}
infowindow[i] = new google.maps.InfoWindow({content:""})
var description = '<h2>'+ ListeDesPoints[i]['address']+'</h2><img src="'+ListeDesPoints[i]['image']+'" />';
CreateMarker(marker[i], map, infowindow[i], description);
}
}
有可能你注意到我做错了其他事情...请,随意批评这段代码:)
非常感谢
如果您希望每个地图都有一个标记,请为每个地图创建一个单独的InfoWindow,并像处理地图一样将其与标记相关联。
for (var i = 0; i < ListeDesPoints.length; i++) {
marker[i] = new google.maps.Marker({
position: new google.maps.LatLng(ListeDesPoints[i]['lat'], ListeDesPoints[i]['lng']),
title: ListeDesPoints[i]['address']
});
var max_lat = 48.9602260;
var min_lat = 48.7451930;
var max_lng = 2.6327379;
var min_lng = 2.0946256;
if (ListeDesPoints[i]['lat'] > max_lat || ListeDesPoints[i]['lat'] < min_lat || ListeDesPoints[i]['lng'] > max_lng || ListeDesPoints[i]['lng'] < min_lng) {
var map = mapfr;
var infowindow = infowindowfr;
} else {
var map = mapidf;
var infowindow = infowindowidf;
}
//infowindow[i] = new google.maps.InfoWindow({ content: "" });
var description = '<h2>' + ListeDesPoints[i]['address'] + '</h2><img src="' + ListeDesPoints[i]['image'] + '" />';
CreateMarker(marker[i], map, infowindow, description);
}
概念验证小提琴
代码段:
function CreateMarker(marker, map, infowindow, description) {
marker.setMap(map);
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(description);
infowindow.open(map, this);
});
}
function initialize(ListeDesPoints) {
var mapidfOptions = {
center: {
lat: 48.856614,
lng: 2.352222
},
zoom: 11
};
var mapfrOptions = {
center: {
lat: 46.227638,
lng: 2.213749
},
zoom: 5
};
var mapidf = new google.maps.Map(document.getElementById('maps-idf'),
mapidfOptions);
var mapfr = new google.maps.Map(document.getElementById('maps-fr'),
mapfrOptions);
//var infowindow = new Array();
var infowindowfr = new google.maps.InfoWindow({});
var infowindowidf = new google.maps.InfoWindow({});
var marker = new Array();
for (var i = 0; i < ListeDesPoints.length; i++) {
marker[i] = new google.maps.Marker({
position: new google.maps.LatLng(ListeDesPoints[i]['lat'], ListeDesPoints[i]['lng']),
title: ListeDesPoints[i]['address']
});
var max_lat = 48.9602260;
var min_lat = 48.7451930;
var max_lng = 2.6327379;
var min_lng = 2.0946256;
if (ListeDesPoints[i]['lat'] > max_lat || ListeDesPoints[i]['lat'] < min_lat || ListeDesPoints[i]['lng'] > max_lng || ListeDesPoints[i]['lng'] < min_lng) {
var map = mapfr;
var infowindow = infowindowfr;
} else {
var map = mapidf;
var infowindow = infowindowidf;
}
//infowindow[i] = new google.maps.InfoWindow({ content: "" });
var description = '<h2>' + ListeDesPoints[i]['address'] + '</h2><img src="' + ListeDesPoints[i]['image'] + '" />';
CreateMarker(marker[i], map, infowindow, description);
}
}
//Usage
google.maps.event.addDomListener(window, 'load', function() {
//1.load data
var points = [{
'lat': 48.856614,
'lng': 2.352222,
'address': 'Paris',
'image':'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5OjcBCgoKDQwNGg8PGjclHyU3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N//AABEIAEgASAMBIgACEQEDEQH/xAAbAAABBQEBAAAAAAAAAAAAAAAFAAEDBAYCB//EADoQAAIBAwMBBgMECAcBAAAAAAECAwAEEQUSITEGEyJBUWEUcYEVQpGhMlKSorHB0fAWIyQlM0NyB//EABkBAAIDAQAAAAAAAAAAAAAAAAQFAQIDAP/EACYRAAICAQMDBAMBAAAAAAAAAAABAgMRBBJRFCExFTIzQRMiIwX/2gAMAwEAAhEDEQA/ALZhxUXewpuzIvh6ir146WUPe3Z7uPONxBP8KBn/AA9K7N37KWyVAWTn+lMNRqfxYwDU0785L5lgbjvFzjPWmDwlMh09PzxVMx9nSBi4kGTjOyQ4+VdCHs+veZuJAF6DY/p60L6hPg36SPJIzKWIBXj3pQyIrA7xz5ZqNo+zokVDduM8nwScc/w6jmm2dntof4tsMRgYk5GSf4emKn1GfBHSR5CTTRGMneoK9eapzDe2Nyk/OoVt+z5OTft4QAW/zOuCDj6ketMbTQsHF8Q2P15MLx1P1yfKuX+hJfR3SR5Oo08WcZ+VKiGmJpkLC3tbgSM5JG8ksfx9qVMK7t8FIFnXtlgKahaPdWU0DvIAynDRttYHyINYP7E1YcCe7ZR0PxXOf2q9OWSJlPOOPMVjb/UL1by5MN5OiLMyKi+WMj1H95pZrfKDNL4YEGjau2RvvCG6/wCq6/vV0NK1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xZHQ2FRSdxnsSuf8AtvRQtAzMARjP8q7DxH+3tRlnrsMdOn0V2hdWpSFI3yp3/GlV0lmgSR9sKdyzY/ftSofIfQfjxM5Kl3bPq0pKNYc6TpJw2r9PYDFQC9bSIp42iOlE1SLsN8lvbsKs41O4Rz/wcV1ShPLmTQTtjtXVKEWcsZNcAcF6JLmJo2xzLpmxn4VABJPYZwaYtwXgs3DgK96ShZeoGAQPfNTz8KttJkRNIUE5jOM4+1QW9nKxintpSrRMGjMi7qcBgR9am8K6Kbsux99csnDr14mAMcgIwdwxbY/hRqSoJlHLkeR1l0j4Q3h6Z86rmgntLS5V1URy7ySDBOwPc/Oo0u4UjXR4+4/ZoPC2qCs1M1xkEduxTlodIxpXLfCB36b0PPxq2t2KXdyquh8KSnUy9+n76Cs7PxK6ubc2/OeFGGC0J0tj51TtwYLJzHuDIh3Kuu7H1IO9Sjpkh56hvg0V5xC/vm18OS2mt025kkytvjyBOD7Gu1X2rR20HLjUAd2G2d6VdCxUR3L7Lh0YMApHMBYDPXKtj75H386kmjS5iWRVGdOpPM57UqVMZoEN7bInLMuskbKoySP16fWgG4zKU028SRY21Yyf0pUqokiLbAJpZJm1Suzn/cc1CGrtKnFFG7q2etEyzkxjJ7UqVLQUwUzHt0pUqVOKf//Z'}];
initialize(points);
});
#maps-fr,
#maps-idf {
height: 240px;
width: 640px;
margin: 0px;
padding: 0px;
}
<script src="https://maps.googleapis.com/maps/api/js"></script>
<div id="maps-fr"></div>
<div id="maps-idf"></div>
本节将帮助您一步一步创建一张地图。该地图的最终效果如下。 分享链接:http://d.dituzhe.com/ShareMap/0EB1C2 1 地图分析 该地图包含两个图层,一个是点图层,指我们的店铺信息。一个是面图层,指我们的销售区域。下面将介绍如何创建这些数据,以及如何将这些数据添加到地图中,并设置数据的显示样式。 2 创建店铺数据 点击首页的“数据管理”页面,进入后点击“新增数据”按钮 在
在LSV中可以实现地形夸张效果的更改,在“视图”菜单栏中“视图角度”栏点击“地形夸张”,最高可以设置地形拉伸效果是10倍,默认值拉伸效果是1倍。 拖动鼠标左键,调整地形拉伸倍数,看下拉伸效果为5倍的效果。 地形夸张是对DEM的缩放,会导致海拔高度发生变化,建议使用默认1.0缩放。
在LSV中可以实现地形夸张效果的更改,在“视图”菜单栏中“视图角度”栏点击“地形夸张”,最高可以设置地形拉伸效果是10倍,默认值拉伸效果是1倍。 拖动鼠标左键,调整地形拉伸倍数,看下拉伸效果为5倍的效果。 地形夸张是对DEM的缩放,会导致海拔高度发生变化,建议使用默认1.0缩放。
问题内容: 我一直在尝试使用Hadoop将N条线发送到单个映射。我不需要将行拆分。 我尝试使用NLineInputFormat,但是,它会将数据中的N行文本一次发送到每个映射器[在第N行之后放弃]。 我试图设置该选项,它只需要N行输入,一次将其发送到每张地图的一行: 我发现了一个邮件列表,建议我重写LineRecordReader :: next,但这并不是那么简单,因为内部数据成员都是私有的。
var Rafael=new google.maps.latlng(52.341949,6.682236);var Aandagt=new google.maps.latlng(52.341949,6.782236); 任何帮助或建议如何添加和附加2个信息,一个为标记'Rafael'和一个为标记'Aandagt'将非常感谢。 查看当前地图:http://www.imrafaelhi.nl/stag
问题内容: 我有两张地图: 我想通过Integer值将此映射组合为一个,因此结果映射为 有什么方法比遍历条目集更容易做到这一点? 问题答案: 假设两个映射的键匹配并且映射具有相同数量的条目,那么使用Java 8可以用以下代码一行编写它: 因此,您从第一个地图开始并创建一个新地图,其中键是mapOne的值,而值是mapTwo中的对应值。 从技术上讲,这在某种程度上等同于迭代第一个映射的条目集。 注意