Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use openlayers draw control in Polymer script. #1109

Closed
purpleP opened this issue Jan 20, 2015 · 4 comments
Closed

Can't use openlayers draw control in Polymer script. #1109

purpleP opened this issue Jan 20, 2015 · 4 comments
Labels

Comments

@purpleP
Copy link

purpleP commented Jan 20, 2015

Full info can be found here.

http://stackoverflow.com/questions/28039895/drawing-doesnt-work-in-openlayers3-with-polymer

<script src="/static/bower_components/openlayers3/build/ol.js" type="text/javascript"></script>
<template>
<style>
        .map {
            height: 100%;
            width: 100%;
        }
    </style>

    <h2>My Map</h2>
    <div id="map" class="map"></div>
</template>

<script>
    Polymer({

        domReady: function() {


            this.map = new ol.Map({
                target: this.$.map,
                layers: [
                  new ol.layer.Tile({
                    source: new ol.source.MapQuest({layer: 'sat'})
                  })
                ],
                view: new ol.View({
                  center: ol.proj.transform([37.41, 8.82], 'EPSG:4326', 'EPSG:3857'),
                  zoom: 4
                })
                });

            var featureOverlay = new ol.FeatureOverlay({
              style: new ol.style.Style({
                fill: new ol.style.Fill({
                  color: 'rgba(255, 255, 255, 0.2)'
                }),
                stroke: new ol.style.Stroke({
                  color: '#ffcc33',
                  width: 2
                }),
                image: new ol.style.Circle({
                  radius: 7,
                  fill: new ol.style.Fill({
                    color: '#ffcc33'
                  })
                })
              })
            });
            featureOverlay.setMap(this.map);


            var modify = new ol.interaction.Modify({
              features: featureOverlay.getFeatures(),
              // the SHIFT key must be pressed to delete vertices, so
              // that new vertices can be drawn at the same position
              // of existing vertices
              deleteCondition: function(event) {
                return ol.events.condition.shiftKeyOnly(event) &&
                    ol.events.condition.singleClick(event);
              }
            });
            this.map.addInteraction(modify);


            var draw = new ol.interaction.Draw({
                features: featureOverlay.getFeatures(),
                type: "LineString"
            });
            this.map.addInteraction(draw);


        }

    })
</script>
@fredj
Copy link
Contributor

fredj commented Mar 4, 2015

It's an openlayers bug, this issue can be closed.

@fredj
Copy link
Contributor

fredj commented Mar 19, 2015

Fixed with openlayers/openlayers#3322

@tjsavage tjsavage added the 0.5 label May 21, 2015
@tjsavage
Copy link
Contributor

Closing this issue due to age and the release of version 1 of Polymer - please feel free to re-open if this is incorrect.

@fredj
Copy link
Contributor

fredj commented Oct 26, 2015

@tjsavage that's fine, the issue is fixed in openlayers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants