1

I'm doing a map to describe trekking paths and I need a button for the geolocation function. I saw ol examples about custom control, button and geolocation, and using the drupal geolocate button I managed to get a map. It works, but I need a marker to locate the position, and I added the following code at row 86, but it doesn't work, I'm doing something wrong?

positionFeature.setStyle(new ol.style.Style({
    image: new ol.style.Circle({
        radius: 6,
        fill: new ol.style.Fill({
        color: '#3399CC'
        }),
        stroke: new ol.style.Stroke({
        color: '#fff',
        width: 2
        })
    })
}));
4

You need to pass the map as a parameter to your control. Map is undefined on the way you pass it. Change the last line of your code

from this

map.addControl(new app.Geolocate());

to this

map.addControl(new app.Geolocate('',map));

check your fiddle with this tiny change here

  • no probs. glad to help. – pavlos Nov 22 '15 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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