Adding line between two popup in openlayer

المشرف العام

Administrator
طاقم الإدارة
if(farmerOrg!=''){ $("*").css("cursor", "progress"); $.post('farmOfficeDistance_populateFarms',{selectedFarmerOrganisation:farmerOrg},function(data){ var arry = JSON.parse(data);
removeExistingVectorLayers(); if(arry.length>0){ var features=[]; for (var i=0; i < arry.length;i++){ if(arry!=""){ var JSONFarmerObj = arry; var latitude = JSONFarmerObj.latitude; var longtitude = JSONFarmerObj.longtitude; var isFarmerOrg = JSONFarmerObj.isFarmerOrg; if (latitude != '' && longtitude != '' && latitude != null && longtitude != null) {

var feature = new OpenLayers.Feature.Vector( new OpenLayers.Geometry.Point(longtitude, latitude).transform( fromProjection, toProjection),{type: isFarmerOrg}); feature.data = JSONFarmerObj; var from = new google.maps.LatLng(arry[arry.length-1].latitude, arry[arry.length-1].longtitude); var to = new google.maps.LatLng(latitude, longtitude); var dist = (google.maps.geometry.spherical.computeDistanceBetween(from, to)/1000).toFixed(2); features.push(feature); } } } var styleMap = new OpenLayers.StyleMap({ 'default' : new OpenLayers.Style({ 'pointRadius' : 15, }), 'select' : new OpenLayers.Style({ 'pointRadius' : 15 })}); var lookup = { 1: {externalGraphic: farmerOrgImage}, 0: {externalGraphic: farmerImage} }; styleMap.addUniqueValueRules("default", "type", lookup); // create the layer with listeners to create and destroy popups farmerVectorLayer = new OpenLayers.Layer.Vector("Points",{ eventListeners:{ 'featureselected':function(evt){ removePopups(); var feature = evt.feature; if(feature.data.isFarmerOrg){ var popup = new OpenLayers.Popup.FramedCloud("", new OpenLayers.LonLat(feature.data.longtitude, feature.data.latitude).transform(fromProjection,toProjection), new OpenLayers.Size(300,100), buildFarmerOrgTable(feature.data.farmerOrg, feature.data.farmerOrgName, feature.data.latitude, feature.data.longtitude), null, true,function() { map.removePopup(this); this.destroy(); delete this; }); }else{ var popup = new OpenLayers.Popup.FramedCloud("", new OpenLayers.LonLat(feature.data.longtitude, feature.data.latitude).transform(fromProjection,toProjection), new OpenLayers.Size(300,100), buildFarmerTable(feature.data.farmerId, feature.data.farmerName, feature.data.communityName, feature.data.farmId, feature.data.farmName, feature.data.latitude, feature.data.longtitude), null, true,function() { map.removePopup(this); this.destroy(); delete this; }); } feature.popup = popup; map.addPopup(popup); } /*'featureunselected':function(evt){ var feature = evt.feature; map.removePopup(feature.popup); feature.popup.destroy(); feature.popup = null; }*/ },styleMap : styleMap }); farmerVectorLayer.addFeatures(features); // create the select feature control var selector = new OpenLayers.Control.SelectFeature(farmerVectorLayer,{ hover:true, autoActivate:true }); map.addLayer(farmerVectorLayer); map.addControl(selector); if(features.length>0){ map.setCenter(new OpenLayers.LonLat(features[length-1].data.longtitude, features[length-1].data.latitude).transform(fromProjection,toProjection), transformZoomLevel, false, false); } }else{ reinitialize(); } $("*").css("cursor", "auto"); }); }else{ reinitialize(); } This is my code. how to add line between two latlong points in this



أكثر...
 
أعلى