egeloen / IvoryGoogleMapBundle

Google Map API v3 integration for your Symfony2 project.
https://github.com/egeloen/ivory-google-map
MIT License
217 stars 152 forks source link

Is implemented Styled Maps ?? #104

Closed eperinan closed 10 years ago

eperinan commented 10 years ago

Hi @egeloen !!

I want to hide all google places markers and I need create an google.maps.StyledMapType.

Is this functionality develop in the Bundle?

This is an page of documentation of google map v3. https://developers.google.com/maps/documentation/javascript/styling

Thanks !

egeloen commented 10 years ago

@ernestoperinan It depends what you would like to do :) Basically, you can already change the styles property in the map option but you can't create your own StyledMapType (you can only change the default value by other pre-configured value...).

egeloen commented 10 years ago

A possible implementation is to wrap an array of custom styled map types in the map and then render them with an new helper in the map helper. The issue will be to find a good way to set it and apply it to the map after it has been instantiated as currently the mapTypeId is setted during the map instantiation through the map options...

eperinan commented 10 years ago

Hi @egeloen !!

I've tried the first comment but don't work, with the next code.

$arrayStyles["stylers"] = array('saturation'=>-20,'hue'=>'#00ffe6'); $map->setMapOption('styles', $arrayStyles);

or

$arrayStyles["stylers"] = array('saturation'=>-20,'hue'=>'#00ffe6'); $arrayStyles = json_encode($arrayStyles); $map->setMapOption('styles', $arrayStyles);

What is wrong in it ?

ceesvanegmond commented 10 years ago

I'm having the same problem, how can we solve this?

egeloen commented 10 years ago

To resume the current situation, the library does not support the creation of custom StyledMapType but you should be able to use the styles property of the map options. IMO, @ernestoperinan makes a mistake in the structure of the custom styles. For example to reflect this structure:

var styles = [
  {
    stylers: [
      { hue: "#00ffe6" },
      { saturation: -20 }
    ]
  }
];

you should use something like:

$map->setMapOption('styles', array(
    array(
        'stylers' => array(
            array('hue' => '#00ffe6'),
            array('saturation' => -20),
        )
    )
));
ceesvanegmond commented 10 years ago

Works! Thx!

eperinan commented 10 years ago

Thanks @egeloen !! You are the best !! Closed this issue !

$map->setMapOption('styles', array(array("featureType"=>"poi",'stylers' => array(array('visibility' => 'off'),array('hue'=> "#ff0000")))));