[OpenLayers-Users] openlayers not showing image
sunny74
sb.ray at hotmail.com
Tue Mar 2 02:38:41 EST 2010
I have an image in my file system.The image is to be shown repeatedly in a
map at different positions(lonlat) bec' it is a tracking.
But openlayers is unable to retrieve the png file from the location and show
it on the map.
When I put the path directly in a browser(IE or Firefox) I see the image.
The function is as below:
function putmarker(longi, latti,wk) {
if (tmarkers != null)
tmarkers.destroy(tmarkers);
tmarkers = new OpenLayers.Layer.Markers("Markers");
//alert(tmarkers);
map.addLayer(tmarkers);
var lon1 = longi; var lat1 = latti;
//alert(lon1);
//alert(lat1);
var size = new OpenLayers.Size(25, 21);
var offset = new OpenLayers.Pixel(-(size.w / 2), -size.h);
//alert(offset);
var icon = new OpenLayers.Icon('D:/WRMaps/Images/marker-blue.png',
size, offset);
//alert(icon);
tmarkers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(longi,
latti), icon));
var x = readCookie('trackingcookie');
if (x) {
//alert('cookie exists');
var cookval = readCookie('trackingcookie');
//alert(cookval);
//var cookarr = [];
cookval1 = cookval.toString();
//var pos1 = cookval1.indexOf('=');
//var pos3 = wktstr.indexOf('t');
//alert(pos1);
// var prevlonlat = cookval1.slice(pos1 + 1, pos3 - 1);
// alert("prevlonlat: " + prevlonlat);
var parser = new OpenLayers.Format.WKT();
var wkt = "LINESTRING(" + cookval1 + "," + wk + ")";
//alert(wkt);
highlight.addFeatures(parser.read(wkt));
//alert("cookarr length "+ cookarr.length);
ResetCokie("trackingcookie", wk, 1);
}
else {
//create the cookie bec' there is no previous point
Createcookie("trackingcookie", longi + ' ' + latti, 1);
//alert('else');
}
}
The icon is not seen on the map.
Later I changed the code and used url instead.But the result is same.
function putmarker(longi, latti,wk) {
if (tmarkers != null)
tmarkers.destroy(tmarkers);
tmarkers = new OpenLayers.Layer.Markers("Markers");
//alert(tmarkers);
map.addLayer(tmarkers);
var timestamp = new Date().getTime();
var url2 = "Http://172.16.0.144:9000/cgi-bin/Shape/marker-blue.png";
url2 += '?' + timestamp;
var lon1 = longi; var lat1 = latti;
//alert(lon1);
//alert(lat1);
var size = new OpenLayers.Size(25, 21);
var offset = new OpenLayers.Pixel(-(size.w / 2), -size.h);
//alert(offset);
var icon = new OpenLayers.Icon(url2, size, offset);
//alert(icon);
tmarkers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(longi,
latti), icon));
tmarkers.setUrl(url2);
var x = readCookie('trackingcookie');
if (x) {
//alert('cookie exists');
var cookval = readCookie('trackingcookie');
//alert(cookval);
//var cookarr = [];
cookval1 = cookval.toString();
//var pos1 = cookval1.indexOf('=');
//var pos3 = wktstr.indexOf('t');
//alert(pos1);
// var prevlonlat = cookval1.slice(pos1 + 1, pos3 - 1);
// alert("prevlonlat: " + prevlonlat);
var parser = new OpenLayers.Format.WKT();
var wkt = "LINESTRING(" + cookval1 + "," + wk + ")";
//alert(wkt);
highlight.addFeatures(parser.read(wkt));
//alert("cookarr length "+ cookarr.length);
ResetCokie("trackingcookie", wk, 1);
}
else {
//create the cookie bec' there is no previous point
Createcookie("trackingcookie", longi + ' ' + latti, 1);
//alert('else');
}
}
Again the icon doesn't show up. So displaying an image using openlayers is a
huge problem.
Any solution??
Thanks for ur reply.
--
View this message in context: http://n2.nabble.com/openlayers-not-showing-image-tp4659520p4659520.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list