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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:59:26+00:00 2026-05-11T07:59:26+00:00

I’ve got geodjango running using openlayers and OpenStreetMaps with the admin app. Now I

  • 0

I’ve got geodjango running using openlayers and OpenStreetMaps with the admin app.

Now I want to write some views to display the data. Basically, I just want to add a list of points (seen in the admin) to the map.

Geodjango appears to use a special openlayers.js file to do it’s magic in the admin. Is there a good way to interface with this?

How can I write a view/template to display the geodjango data on a open street map window, as is seen in the admin?

At the moment, I’m digging into the openlayers.js file and api looking for an ‘easy’ solution. (I don’t have js experience so this is taking some time.)

The current way I can see to do this is add the following as a template, and use django to add the code needed to display the points. (Based on the example here)

<html xmlns='http://www.w3.org/1999/xhtml'>     <head>         <title>Draw Feature Example</title>          <script src='http://www.openlayers.org/api/OpenLayers.js'></script>       <script type='text/javascript'>             var map;              function init(){                 map = new OpenLayers.Map('map');                 var layer = new OpenLayers.Layer.WMS( 'OpenLayers WMS',                         'http://labs.metacarta.com/wms/vmap0', {layers: 'basic'} );                 map.addLayer(layer);                  /*                  * Layer style                  */                 // we want opaque external graphics and non-opaque internal graphics                 var layer_style = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);                 layer_style.fillOpacity = 0.2;                 layer_style.graphicOpacity = 1;                  /*                  * Blue style                  */                 var style_blue = OpenLayers.Util.extend({}, layer_style);                 style_blue.strokeColor = 'blue';                 style_blue.fillColor = 'blue';                 style_blue.graphicName = 'star';                 style_blue.pointRadius = 10;                 style_blue.strokeWidth = 3;                 style_blue.rotation = 45;                 style_blue.strokeLinecap = 'butt';                  var vectorLayer = new OpenLayers.Layer.Vector('Simple Geometry', {style: layer_style});                  // create a point feature                 var point = new OpenLayers.Geometry.Point(-111.04, 45.68);                 var pointFeature = new OpenLayers.Feature.Vector(point,null,style_blue);                 // Add additional points/features here via django                  map.addLayer(vectorLayer);                 map.setCenter(new OpenLayers.LonLat(point.x, point.y), 5);                 vectorLayer.addFeatures([pointFeature]);             }         </script>     </head>     <body onload='init()'>         <div id='map' class='smallmap'></div>     </body> </html> 

Is this how it’s done, or is there a better way?

  • 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. 2026-05-11T07:59:26+00:00Added an answer on May 11, 2026 at 7:59 am

    I think your solution is workable and probably the easiest approach. Just templatize the javascript and use Django to inject your data points as the template is rendered.

    If you wanted to get fancier, you could have a Django view that served up the data points as JSON (application/json) and then use AJAX to call back and retrieve the data based on events that are happening in the browser. If you want your application to be highly interactive above and beyond what OpenLayers provides, this might be worth the added complexity, but of course it all depends on the needs of your application.

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

Sidebar

Ask A Question

Stats

  • Questions 104k
  • Answers 104k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Sorry, I got it figured out. You need to download… May 11, 2026 at 8:30 pm
  • Editorial Team
    Editorial Team added an answer Take a look at the MouseEventArgs class. Specifically the GetPosition… May 11, 2026 at 8:30 pm
  • Editorial Team
    Editorial Team added an answer I guess what you want is: @title = tokens[Title] @title.strip!… May 11, 2026 at 8:30 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.