0

I use ol3-google-maps and when I switch layer from standard OSM to Google then styles are broken. I have defined styles but Google use self for example: points in OSM are yellow but when is google-map point shows like Google marker.

Google layers:

var GM = new olgm.layer.Google({
         mapTypeId: 'hybrid',
         title: 'Google',
         type: 'base'
    });

var olGM = new olgm.OLGoogleMaps({map: map,mapIconOptions: {useCanvas: true }}); 
    olGM.activate();
    manager['main_google'].setVisible(false);

Style:

function pointStyleFunction(feature) {
return 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'
        })
    }),
    text: createTextStyle(feature)
  });
}

Layers of features:

var layer_ambon = new ol.layer.Vector({
                source: new ol.source.Vector({ features: new ol.Collection((new ol.format.GeoJSON()).readFeatures(map_info['layers'][3])) })
            });

Standard OL map:

map = new ol.Map({
        interactions: olgm.interaction.defaults(),
        target: olMapDiv,
        layers: [
          OSM,  
          GM,
        ],
        controls: ol.control.defaults().extend([
            new ol.control.ScaleLine()
        ]),
        view: view
    });
2
  • Would you please share some code? How do are the feature styled? Can you share a live example? By the way, be aware that if you use features that come from Google, then they must be shown on top of Google layers. Commented Apr 26, 2017 at 12:42
  • I share some code. Commented Apr 26, 2017 at 15:56

1 Answer 1

0

Style Functions in OpenLayers are not compatible with ol3-google-maps. See the LIMITATION.

As an alternative, you can either:

  1. manually set the style directly within each feature instead, which would avoid the use of the style function
  2. keep the style function and turn off the vectors watcher in ol3-google-maps. See the ol3gm Watch Options example to see how to turn it off.

Here's a snippet for (2):

var olGM = new olgm.OLGoogleMaps({
  map: map,
  watch: {
    'vector': false
  }
});
olGM.activate();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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