Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8582431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:17:28+00:00 2026-06-11T21:17:28+00:00

As in example http://openlayers.org/dev/examples/graphic-name.html … I tried drawing my feature geometry as a flag

  • 0

As in example http://openlayers.org/dev/examples/graphic-name.html …
I tried drawing my feature geometry as a flag but I realized that OpenLayers always uses the centroid of the geometry to place the feature at the specified point(latitude/longitude), whereas I wish the base of the flag to be placed at the specified point. Changing the value of Renderer.symbol did not make any effect neither did the graphicXOffset/graphicYOffset.

//my flag geometry
OpenLayers.Renderer.symbol.flag = [0, 0, 0, 140, 120, 140, 120, 60, 4, 60, 4, 0, 0, 0];

//create vector layer with default and select styles
myVectorLayer = new OpenLayers.Layer.Vector("Flag Geometry", {
    renderers: renderer,
    isBaseLayer: true,
    graphicName: flag,
    rotation: 180,
    pointRadius: 15,
    projection: new OpenLayers.Projection("EPSG:900913"),
    styleMap: new OpenLayers.StyleMap({
        "default": new OpenLayers.Style(OpenLayers.Util.applyDefaults({
            fillColor: "red",
            strokeColor: "gray",
            label: "${label}",
            fontColor: "${favColor}",
            fontSize: "12px",
            fontFamily: "Courier New, monospace",
            fontWeight: "bold",
            labelYOffset: 2 //for flag
        }, OpenLayers.Feature.Vector.style["default"])),
        "select": new OpenLayers.Style(OpenLayers.Util.applyDefaults({
        }, OpenLayers.Feature.Vector.style["select"]))
    })
});

var flag = new OpenLayers.Geometry.Point(latitude, longitude);
var flagFeature = new OpenLayers.Feature.Vector(flag);
myVectorLayer.addFeatures([flagFeature]);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:17:30+00:00Added an answer on June 11, 2026 at 9:17 pm

    To overcome this base point problem I changed the drawing method as follows:

    myVectorLayer = new OpenLayers.Layer.Vector("Flag Geometry", {
    renderers: renderer,
    isBaseLayer: true,
    projection: new OpenLayers.Projection("EPSG:900913"),
    styleMap: new OpenLayers.StyleMap({
        "default": new OpenLayers.Style(OpenLayers.Util.applyDefaults({
            fillColor: "red",
            strokeColor: "gray",
            label: "${label}",
            fontColor: "${favColor}",
            fontSize: "12px",
            fontFamily: "Courier New, monospace",
            fontWeight: "bold",
            labelYOffset: 2 //for flag
        }, OpenLayers.Feature.Vector.style["default"])),
            "select": new OpenLayers.Style(OpenLayers.Util.applyDefaults({
        }, OpenLayers.Feature.Vector.style["select"]))
    })
    });
    
    var pointList = [];
    var xs = [0, 0, 240, 240, 8, 8, 0];
    var ys = [0, 280, 280, 120, 120, 0, 0];
    
    for(var p=0; p<6; ++p) {
        var newPoint = new OpenLayers.Geometry.Point(camera.get('latitude') + xs[p],
            camera.get('longitude') + ys[p]);
    
        pointList.push(newPoint);
    }
    pointList.push(pointList[0]);
    var linearRing = new OpenLayers.Geometry.LinearRing(pointList);
    var flagVector = new OpenLayers.Feature.Vector(
            new OpenLayers.Geometry.Polygon([linearRing]));
    
    flagVector.attributes= {
        label: 'label',
        favColor: 'blue', //favorite color
        align: "cm"
    };
    myVectorLayer.addFeatures([flagVector]);
    

    This though will make the geometry zoom with map zoom not as the previous way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm drawing points on a map with OpenLayers like in this example: http://dev.openlayers.org/examples/draw-feature.html Now
i'm trying to implement the example http://openlayers.org/dev/examples/drag-feature.html . When i'm implementing this with a
Hy, I'm working on a jsFiddle with a openlayers example in it. http://dev.openlayers.org/releases/OpenLayers-2.11/examples/snapping.html At
Hi i try to do that example http://openlayers.org/dev/examples/all-overlays.html in my django application. I use
The default strategy for OpenLayers is Fixed. See for example: http://openlayers.org/dev/examples/sundials.html var sundials =
I want to implement this example http://api.geoext.org/1.1/examples/feature-grid.html made of geoext and openlayers, that feature
I made a jsf project and have the following example from http://docs.openlayers.org/library/introduction.html but as
Example: http://mrdoob.github.com/three.js/examples/canvas_geometry_birds.html I wish to incorporate the above script into my one home page
we have this example: http://code.google.com/apis/maps/documentation/v3/basics.html#DetectingUserLocation which shows how to get the user's position in
Take the PriorityQueue for example http://java.sun.com/j2se/1.5.0/docs/api/java/util/PriorityQueue.html#offer(E) Can anyone give me an example of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.