OS OpenSpace [logo]

OS OpenSpace Forum » OS OpenSpace » Newbie Area

Thread: Marker with openlayers/geoserver ( help! )

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 2 - Pages: 1 - Last Post: 03-Mar-2012 00:38 by: Guest
Marker with openlayers/geoserver ( help! )
Posted: 02-Mar-2012 03:54
  Click to reply to this thread Reply

[nobr]Hi All!
My name's Tony. I'm from vietnam. I want add a marker in webgis with openlayers/geoserver. Here my code :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<!-- Import OL CSS, auto import does not work with our minified OL.js build -->
<link rel="stylesheet" type="text/css" href="http://localhost:8080/geoserver/openlayers/theme/default/style.css"/>
<!-- Basic CSS definitions -->
<style type="text/css">
/* General settings */
body {
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: small;

/* The map and the location bar */
#map {
clear: both;
position: relative;
width: 1350px;
height: 600px;
border: 0px solid black;


<!-- Import OpenLayers, reduced, wms read only version -->
<script src="http://localhost:8080/geoserver/openlayers/OpenLayers.js" type="text/javascript">
<script defer="defer" type="text/javascript">
var map;
var untiled;
var tiled;
var pureCoverage = false;

// pink tile avoidance
// make OL compute scale according to WMS spec
OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;

function init(){
// if this is just a coverage or a group of them, disable a few items,
// and default to jpeg format
format = 'image/png';

var bounds = new OpenLayers.Bounds(
143.83482400000003, -43.648056,
148.47914100000003, -39.573891
var options = {
controls: [],
maxExtent: bounds,
maxResolution: 0.01814186328125,
projection: "EPSG:4326",
units: 'degrees'
map = new OpenLayers.Map('map', options);

// setup tiled layer
tiled = new OpenLayers.Layer.WMS(
"Geoserver layers - Tiled", "http://localhost:8080/geoserver/wms",
LAYERS: 'tasmania',
format: format,
tiled: true,
tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom
buffer: 0,
displayOutsideMaxExtent: true,
isBaseLayer: true,
yx : {'EPSG:4326' : true}


// build up all controls
map.addControl(new OpenLayers.Control.PanZoomBar({
position: new OpenLayers.Pixel(2, 15)
map.addControl(new OpenLayers.Control.Navigation());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new OpenLayers.Control.MousePosition({element: $('location')}));

var markers = new OpenLayers.Layer.Markers( "Markers" );

var size = new OpenLayers.Size(21,25);
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
var icon = new OpenLayers.Icon('http://localhost:8080/geoserver/openlayers/img/marker.png', size, offset);
markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(146.83482400000003, -42.648056),icon));
markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(146.47914100000003, -41.573891),icon.clone()));

// support GetFeatureInfo
map.events.register('click', map, function (e) {
document.getElementById('nodelist').innerHTML = "Loading... please wait...";
var params = {
REQUEST: "GetFeatureInfo",
EXCEPTIONS: "application/vnd.ogc.se_xml",
BBOX: map.getExtent().toBBOX(),
INFO_FORMAT: 'text/html',
QUERY_LAYERS: map.layers[0].params.LAYERS,
Layers: 'tasmania',
WIDTH: map.size.w,
HEIGHT: map.size.h,
format: format,
styles: map.layers[0].params.STYLES,
srs: map.layers[0].params.SRS};

OpenLayers.loadURL("http://localhost:8080/geoserver/wms", params, this, setHTML, setHTML);

<body onload="init()">


My problem : It not show a marker, just a webmap. I don't known why. Please help me fix it. Here my webmap :
Thank you for helping!

OS OpenSpace Team

Posts: 1,117
Registered: 31/01/08
Re: Marker with openlayers/geoserver ( help! )
Posted: 02-Mar-2012 10:45   in response to: Guest
  Click to reply to this thread Reply


We have taken a look at your application and can see that you are not using OS OpenSpace specifically but are using Openlayers to call your own Geoserver implementation, both of which are entirely independent and have their own support which can be found here:




Kind regards

OS OpenSpace Team

Re: Marker with openlayers/geoserver ( help! )
Posted: 03-Mar-2012 00:38   in response to: OS OpenSpace Team
  Click to reply to this thread Reply

Thank you !

Expert: 51 - 1000 pts
Advanced: 31 - 50 pts
Intermediate: 16 - 30 pts
Novice: 5 - 15 pts
Newbie: 0 - 4 pts
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums