Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have markers on pressing to which popup has to be brought. how to make it? (coordinates of markers undertake from a DB)

var map;
var markers;

function ejecutar() {
function init(b,kor_1,kor_2) {
    if (b == 3) {
        map = new OpenLayers.Map("basicMap", {
            controls: [
                new OpenLayers.Control.Navigation(),
                new OpenLayers.Control.PanZoomBar(),
                new OpenLayers.Control.LayerSwitcher(),
                new OpenLayers.Control.Attribution()],
            maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
            maxResolution: 156543.0399,
            numZoomLevels: 2,
            units: 'm',
            projection: new OpenLayers.Projection("EPSG:900913"),
            displayProjection: new OpenLayers.Projection("EPSG:4326")

    layerMapnik = new OpenLayers.Layer.OSM.Mapnik("MapaCiudad");
    var lonLat = new OpenLayers.LonLat(50.5206298828125, 55.15881723298661).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
    //map.setCenter(new OpenLayers.LonLat(-3.862788677215576, 43.4669443349282) // Center of the map
    map.setCenter(lonLat, 19);

    //создаем дорогу

    var lineLayer = new OpenLayers.Layer.Vector("Линии"); 
    map.addControl(new OpenLayers.Control.DrawFeature(lineLayer, OpenLayers.Handler.Path));

    var points = new Array(
       new OpenLayers.Geometry.Point(37.61556, 55.75222),
       new OpenLayers.Geometry.Point(45, 33),
       new OpenLayers.Geometry.Point(49, 35),
       new OpenLayers.Geometry.Point(45, 56),
       new OpenLayers.Geometry.Point(49, 87)

    var line = new OpenLayers.Geometry.LineString(points);
    line.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));

    var style = { 
        strokeColor: '#0000ff', 
        strokeOpacity: 0.5,
        strokeWidth: 5

    var lineFeature = new OpenLayers.Feature.Vector(line, null, style);

    var popup = new OpenLayers.Popup.FramedCloud(
             '<div style="color:#FF0000">' + '</br><a href="http://test.url">test.url</a>' + '</div>',

    //добавление на карту 
    map.addPopup(popup, true);

    //создаем маркер
    markers = new OpenLayers.Layer.Markers("Marcadores");

    if (b == 2) 

            //=================  =========стили для маркеров и тут хранятся координаты
            var size = new OpenLayers.Size(30, 30);
            var offset = new OpenLayers.Pixel(-(size.w / 2), -size.h);

            var location = new OpenLayers.LonLat(kor_1, kor_2).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
            var icon = new OpenLayers.Icon('', size, offset);
            markers.addMarker(new OpenLayers.Marker(location, icon.clone()));



    function add_metka()
        function dobavit(koor1, koor2)


    @foreach (Дорожное_строительство.Models.koordinats_piket picket  in ViewBag.Data)


    setTimeout('add_metka()', 6000)

share|improve this question
I didn't understand what you need, en espanhol mejor? =) – Gery May 17 '13 at 7:50
from russia)by pressing a marker to make the to make it? – user2390000 May 17 '13 at 9:38

I thought it was spanish because you have "Marcadores". Anyway check this, basically you need:

var popup = new OpenLayers.Popup.FramedCloud(
                '<div style="color:#FF0000">' + '</br><a href="http://test.url">test.url</a>' + '</div>',
share|improve this answer
i add this work..((((Maybe to this code still it is necessary to add something? – user2390000 May 17 '13 at 9:56
post your whole code, in that way is easier to see what is your problem – Gery May 17 '13 at 10:02
I edited the code. (I added the whole code) – user2390000 May 17 '13 at 10:19
you need to modify the popup according to your code, the example above is just an example, I think your problem is feature.geometry.toShortString(), for more examples check this – Gery May 17 '13 at 10:27"click", markers, function(e){ popup = new OpenLayers.Popup("chicken", map.getLonLatFromPixel(e.x), new OpenLayers.Size(200,200), "example popup", true); map.addPopup(popup); }); – user2390000 May 17 '13 at 12:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.