[Mapbender-commits] r5615 - trunk/mapbender/lib
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Feb 24 04:23:57 EST 2010
Author: christoph
Date: 2010-02-24 04:23:55 -0500 (Wed, 24 Feb 2010)
New Revision: 5615
Modified:
trunk/mapbender/lib/marker.js
Log:
added custom marker images
Modified: trunk/mapbender/lib/marker.js
===================================================================
--- trunk/mapbender/lib/marker.js 2010-02-24 09:00:20 UTC (rev 5614)
+++ trunk/mapbender/lib/marker.js 2010-02-24 09:23:55 UTC (rev 5615)
@@ -1,4 +1,26 @@
Mapbender.Marker = function (p, map) {
+ var options = {};
+ if (arguments.length > 2 && typeof arguments[2] === "object") {
+ options = arguments[2];
+ }
+
+ // override default marker image
+ if (typeof options.img === "object" && options.img.url) {
+ if (typeof options.img.offset !== "object" ||
+ options.img.offset.x === undefined ||
+ options.img.offset.y === undefined
+ ) {
+ options.img.offset = new Point(0, 0);
+ }
+ }
+ // default marker image
+ else {
+ options.img = {
+ url: "../img/marker/red.png",
+ offset: new Point(-10, -34)
+ };
+ }
+
var id = map.elementName + "_" + parseInt(Math.random()*100000,10);
var h = new Highlight(
[map.elementName],
@@ -9,9 +31,15 @@
var g = new MultiGeometry(geomType.point);
g.addGeometry(geomType.point);
g.get(-1).add(p);
- g.e.setElement("Mapbender:icon", "../img/marker/red.png");
- g.e.setElement("Mapbender:iconOffsetX", -10);
- g.e.setElement("Mapbender:iconOffsetY", -34);
+
+ g.e.setElement("Mapbender:icon", options.img.url);
+ g.e.setElement("Mapbender:iconOffsetX", options.img.offset.x);
+ g.e.setElement("Mapbender:iconOffsetY", options.img.offset.y);
+
+ if (options.img.width !== undefined && options.img.height !== undefined) {
+ g.e.setElement("Mapbender:iconWidth", options.img.width);
+ g.e.setElement("Mapbender:iconHeight", options.img.height);
+ }
h.add(g);
h.paint();
More information about the Mapbender_commits
mailing list