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 4585640
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:31:28+00:00 2026-05-21T21:31:28+00:00

I am very new to Openlayers and I am trying out TMS layer for

  • 0

I am very new to Openlayers and I am trying out TMS layer for tiled images generated using gdal2tiles. Basic things like panning/zooming works fine and now I am trying to add editingToolbar and draw some polygons on the map. As soon as I draw the polygon or place the point on the map, the polygon/point disappears. Am I missing anything? How do I debug this?

Here is my code (I am trying it on the html generated by gdal2tiles).

<script type="text/javascript">

            var map;

            var mapBounds = new OpenLayers.Bounds( 0.0, -612.0, 857.0, 0.0);
            var mapMinZoom = 0;
            var mapMaxZoom = 2;

            // avoid pink tiles
            OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
            OpenLayers.Util.onImageLoadErrorColor = "transparent";

            function init(){
            var options = {
                controls: [],
                maxExtent: new OpenLayers.Bounds(  0.0, -612.0, 857.0, 0.0 ),
                maxResolution: 4.000000,
                numZoomLevels: 3
                };
            map = new OpenLayers.Map('map', options);

            var layer = new OpenLayers.Layer.TMS( "TMS Layer","",
                {  url: '', serviceVersion: '.', layername: '.', alpha: true,
                    type: 'png', getURL: overlay_getTileURL
                });
            map.addLayer(layer);
            map.zoomToExtent( mapBounds );   

            map.addControl(new OpenLayers.Control.PanZoomBar());
            map.addControl(new OpenLayers.Control.MousePosition());
            map.addControl(new OpenLayers.Control.MouseDefaults());
            map.addControl(new OpenLayers.Control.KeyboardDefaults());

        var vlayer = new OpenLayers.Layer.Vector( "Editable" );

        map.addControl(new OpenLayers.Control.EditingToolbar(vlayer));

        }

        function overlay_getTileURL(bounds) {
            var res = this.map.getResolution();
            var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
            var y = Math.round((bounds.bottom - this.maxExtent.bottom) / (res * this.tileSize.h));
            var z = this.map.getZoom();
            if (x >= 0 && y >= 0) {
                return this.url + z + "/" + x + "/" + y + "." + this.type;               
            } else {
                return "http://www.maptiler.org/img/none.png";
            }
        }


        </script>
  • 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-05-21T21:31:28+00:00Added an answer on May 21, 2026 at 9:31 pm

    You must add the vector layer to the map as well.

    var vlayer = new OpenLayers.Layer.Vector( "Editable" );
    map.addLayer(vlayer); // HERE
    map.addControl(new OpenLayers.Control.EditingToolbar(vlayer));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is very fast in all browsers: var curLayer = new OpenLayers.Layer.Text(layer, { location:
I am very new to OpenLayers, been using Google Maps for awhile but want
Very new to working with Visual Basic / Excel. I am trying to write
Very new to JQuery and MVC and webdevelopment over all. I'm now trying to
Very new to using Raphael.js I'm looking at the tutorials and I am able
Very new mobile developer here... I am trying to retrieve a list of tweets
Im very new in C++ I have found this post http://msdn.microsoft.com/en-us/magazine/cc163486.aspx and trying to
Very new to Fitnesse, I need to write a test using regular expressions to
Very new to iOS coding. I'd like to be able to display a modal
im very new to this and have a very basic knowledge php and SQL

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.