Vector 从google电子表格导入的标记的OpenLayer弹出窗口
我正在寻找一种在当前设置中使用framecloud类型弹出窗口的方法。不幸的是,我所有的尝试要么都不起作用,要么只能在最近放置的maker上起作用 在尝试使其工作的过程中,我将我的原始脚本从使用标记转换为使用向量来放置标记点(正如我所看到的,自定义向量比自定义标记更容易) 现在我会用哪一个来工作,但在做了几天之后,我已经不知所措了,需要一个正确方向的帮助 我的观点来自使用tabletop.js的谷歌电子表格。该功能正在按照我希望的方式工作,标记基于一个我称为“类型”的字段放置在各自的层上。 虽然我觉得这可能是我的Markers类型层问题的根源,但我不确定如何修复它 您可以通过这些页面查看编码 (由于位置更改,链接已删除。)Vector 从google电子表格导入的标记的OpenLayer弹出窗口,vector,map,popup,openlayers,Vector,Map,Popup,Openlayers,我正在寻找一种在当前设置中使用framecloud类型弹出窗口的方法。不幸的是,我所有的尝试要么都不起作用,要么只能在最近放置的maker上起作用 在尝试使其工作的过程中,我将我的原始脚本从使用标记转换为使用向量来放置标记点(正如我所看到的,自定义向量比自定义标记更容易) 现在我会用哪一个来工作,但在做了几天之后,我已经不知所措了,需要一个正确方向的帮助 我的观点来自使用tabletop.js的谷歌电子表格。该功能正在按照我希望的方式工作,标记基于一个我称为“类型”的字段放置在各自的层上。 虽然
提前谢谢你的帮助。我终于让它开始工作了。对于任何处于类似情况的人,这里是我的层的最终代码。我确实更改了图层的名称,使其与原来的名称不同,并使我使用的电子表格变黑,但这些更改应该是明显的
//
//// Set 'Markers'
//
var iconMarker = {externalGraphic: 'http://www.openlayers.org/dev/img/marker.png', graphicHeight: 21, graphicWidth: 16};
var iconGeo = {externalGraphic: './images/fortress.jpg', graphicHeight: 25, graphicWidth: 25};
var iconAero = {externalGraphic: './images/aeropolae.jpg', graphicHeight: 25, graphicWidth: 25}; // Image is the creation of DriveByArtist: http://drivebyartist.deviantart.com/
var vector1 = new OpenLayers.Layer.Vector("1");
var vector2 = new OpenLayers.Layer.Vector("2");
var vector3 = new OpenLayers.Layer.Vector("3");
// Pulls map info from Spreadsheet
//*
Tabletop.init({
key: 'http://xxxxxxxxxx', //Spreadsheet URL goes here
callback: function(data, tabletop) {
var i,
dataLength = data.length;
for (i=0; i<dataLength; i++) { //following are variables from the spreadsheet
locName = data[i].name;
locLon = data[i].long;
locLat = data[i].lat;
locInfo = data[i].info;
locType = data[i].type; // Contains the following string in the cell, which provides a pre-determined output based on provided information in the spreadsheet: =ARRAYFORMULA("<h2>"&B2:B&"</h2><b>"&G2:G&"</b><br /> "&C2:C&", "&D2:D&"<br />"&E2:E&if(ISTEXT(F2:F),"<br /><a target='_blank' href='"&F2:F&"'>Read More...</a>",""))
locLonLat= new OpenLayers.Geometry.Point(locLon, locLat);
switch(locType)
{
case "Geopolae":
feature = new OpenLayers.Feature.Vector(
locLonLat,
{description:locInfo},
iconGeo);
vector1.addFeatures(feature);
break;
case "POI":
feature = new OpenLayers.Feature.Vector(
locLonLat,
{description:locInfo},
iconMarker);
vector2.addFeatures(feature);
break;
case "Aeropolae":
feature = new OpenLayers.Feature.Vector(
locLonLat,
{description:locInfo},
iconAero);
vector3.addFeatures(feature);
break;
}
}
},
simpleSheet: true
});
map.addLayers([vector1, vector2, vector3]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
//Add a selector control to the vectorLayer with popup functions
var controls = {
selector: new OpenLayers.Control.SelectFeature(Array(vector1, vector2, vector3), { onSelect: createPopup, onUnselect: destroyPopup })
};
function createPopup(feature) {
feature.popup = new OpenLayers.Popup.FramedCloud("pop",
feature.geometry.getBounds().getCenterLonLat(),
null,
'<div class="markerContent">'+feature.attributes.description+'</div>',
null,
true,
function() { controls['selector'].unselectAll(); }
);
feature.popup.autoSize = true;
feature.popup.minSize = new OpenLayers.Size(400,100);
feature.popup.maxSize = new OpenLayers.Size(400,800);
feature.popup.fixedRelativePosition = true;
feature.popup.overflow ="auto";
//feature.popup.closeOnMove = true;
map.addPopup(feature.popup);
}
function destroyPopup(feature) {
feature.popup.destroy();
feature.popup = null;
}
map.addControl(controls['selector']);
controls['selector'].activate();
}
//
////设置“标记”
//
var iconMarker={externalGraphic:'http://www.openlayers.org/dev/img/marker.png,图形高度:21,图形宽度:16};
var iconGeo={externalGraphic:'./images/forester.jpg',graphicsheight:25,graphicswidth:25};
var iconAero={externalGraphic:'./images/aeropolae.jpg',graphicsheight:25,graphicswidth:25};//图像是DriveByArtist的创作:http://drivebyartist.deviantart.com/
var vector1=新的OpenLayers.Layer.Vector(“1”);
var vector2=新的OpenLayers.Layer.Vector(“2”);
var vector3=新的OpenLayers.Layer.Vector(“3”);
//从电子表格中提取地图信息
//*
Tabletop.init({
键:'http://xxxxxxxxxx“,//电子表格URL位于此处
回调:函数(数据,桌面){
var i,
dataLength=data.length;
对于(i=0;i我终于让它开始工作了。对于任何处于类似情况的人,这里是我对层的最终代码。我确实更改了层的名称,使其与原来的名称不同,并使我使用的电子表格变黑,但这些更改应该是显而易见的
//
//// Set 'Markers'
//
var iconMarker = {externalGraphic: 'http://www.openlayers.org/dev/img/marker.png', graphicHeight: 21, graphicWidth: 16};
var iconGeo = {externalGraphic: './images/fortress.jpg', graphicHeight: 25, graphicWidth: 25};
var iconAero = {externalGraphic: './images/aeropolae.jpg', graphicHeight: 25, graphicWidth: 25}; // Image is the creation of DriveByArtist: http://drivebyartist.deviantart.com/
var vector1 = new OpenLayers.Layer.Vector("1");
var vector2 = new OpenLayers.Layer.Vector("2");
var vector3 = new OpenLayers.Layer.Vector("3");
// Pulls map info from Spreadsheet
//*
Tabletop.init({
key: 'http://xxxxxxxxxx', //Spreadsheet URL goes here
callback: function(data, tabletop) {
var i,
dataLength = data.length;
for (i=0; i<dataLength; i++) { //following are variables from the spreadsheet
locName = data[i].name;
locLon = data[i].long;
locLat = data[i].lat;
locInfo = data[i].info;
locType = data[i].type; // Contains the following string in the cell, which provides a pre-determined output based on provided information in the spreadsheet: =ARRAYFORMULA("<h2>"&B2:B&"</h2><b>"&G2:G&"</b><br /> "&C2:C&", "&D2:D&"<br />"&E2:E&if(ISTEXT(F2:F),"<br /><a target='_blank' href='"&F2:F&"'>Read More...</a>",""))
locLonLat= new OpenLayers.Geometry.Point(locLon, locLat);
switch(locType)
{
case "Geopolae":
feature = new OpenLayers.Feature.Vector(
locLonLat,
{description:locInfo},
iconGeo);
vector1.addFeatures(feature);
break;
case "POI":
feature = new OpenLayers.Feature.Vector(
locLonLat,
{description:locInfo},
iconMarker);
vector2.addFeatures(feature);
break;
case "Aeropolae":
feature = new OpenLayers.Feature.Vector(
locLonLat,
{description:locInfo},
iconAero);
vector3.addFeatures(feature);
break;
}
}
},
simpleSheet: true
});
map.addLayers([vector1, vector2, vector3]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
//Add a selector control to the vectorLayer with popup functions
var controls = {
selector: new OpenLayers.Control.SelectFeature(Array(vector1, vector2, vector3), { onSelect: createPopup, onUnselect: destroyPopup })
};
function createPopup(feature) {
feature.popup = new OpenLayers.Popup.FramedCloud("pop",
feature.geometry.getBounds().getCenterLonLat(),
null,
'<div class="markerContent">'+feature.attributes.description+'</div>',
null,
true,
function() { controls['selector'].unselectAll(); }
);
feature.popup.autoSize = true;
feature.popup.minSize = new OpenLayers.Size(400,100);
feature.popup.maxSize = new OpenLayers.Size(400,800);
feature.popup.fixedRelativePosition = true;
feature.popup.overflow ="auto";
//feature.popup.closeOnMove = true;
map.addPopup(feature.popup);
}
function destroyPopup(feature) {
feature.popup.destroy();
feature.popup = null;
}
map.addControl(controls['selector']);
controls['selector'].activate();
}
//
////设置“标记”
//
var iconMarker={externalGraphic:'http://www.openlayers.org/dev/img/marker.png,图形高度:21,图形宽度:16};
var iconGeo={externalGraphic:'./images/forester.jpg',graphicsheight:25,graphicswidth:25};
var iconAero={externalGraphic:'./images/aeropolae.jpg',graphicHeight:25,graphicWidth:25};//图像是DriveByArtist的创作:http://drivebyartist.deviantart.com/
var vector1=新的OpenLayers.Layer.Vector(“1”);
var vector2=新的OpenLayers.Layer.Vector(“2”);
var vector3=新的OpenLayers.Layer.Vector(“3”);
//从电子表格中提取地图信息
//*
Tabletop.init({
键:'http://xxxxxxxxxx“,//电子表格URL位于此处
回调:函数(数据,桌面){
var i,
dataLength=data.length;
对于(i=0;i