WordPress.org

Ready to get started?Download WordPress

Forums

Comprehensive Google Map Plugin
How to Style with JSON Code (5 posts)

  1. ShermanOne
    Member
    Posted 1 year ago #

    The Google Maps API provides the possibility to style a map.
    Where and how do I setup the code I get from

    http://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html

    For example here:
    http://tips4php.net/2010/06/style-your-google-maps-with-json/

    it says how to add the code to html, but how about PHP?

    best regards

    http://wordpress.org/extend/plugins/comprehensive-google-map-plugin/

  2. lukehm
    Member
    Posted 1 year ago #

    I wondered this too.
    I know hoe to do this with my own map.
    Is it possible to style the map created by CGMP by adding some inline js?
    Many Thanks

  3. mckeene
    Member
    Posted 10 months ago #

    Did you ever figure out how this was done?

  4. macambulance
    Member
    Posted 8 months ago #

    I finally figured this one out, you have to add to the json-string parameter in the object, and tell the javascript file to pick up that style from the object. Here's what I did, you might be able to suggest better code :

    1. In the cmgp plugin directory > short code.php > line #74 : $map_data_properties['styles'] = *your style info here as a json formatted string*
    2. In the cmgp plugin directory > assets > js > cgmp.framework.min.js file > line #2
      1. change : b.maptypecontrol,panControl:"true"===b.pancontrol,zoomControl:"true"===b.zoomcontrol,scaleControl:"true"===b.scalecontrol,scrollwheel:"true"===b.scrollwheelcontrol,streetViewControl:"true"===b.streetviewcontrol,tilt:"true"===b.tiltfourtyfive?45:null,draggable:"true"===b.draggable,overviewMapControl:!0,overviewMapControlOptions:{opened:!1}});"true"===b.showpanoramio&&p.buildPanoramioLayer(b.panoramiouid);"true"===b.showbike&&p.buildBikeLayer();"true"===b.showtraffic&&p.buildTrafficLayer();null!=b.kml&&
      2. to : b.maptypecontrol,panControl:"true"===b.pancontrol,zoomControl:"true"===b.zoomcontrol,scaleControl:"true"===b.scalecontrol,scrollwheel:"true"===b.scrollwheelcontrol,streetViewControl:"true"===b.streetviewcontrol,tilt:"true"===b.tiltfourtyfive?45:null,styles:b.styles,draggable:"true"===b.draggable,overviewMapControl:!0,overviewMapControlOptions:{opened:!1}});"true"===b.showpanoramio&&p.buildPanoramioLayer(b.panoramiouid);"true"===b.showbike&&p.buildBikeLayer();"true"===b.showtraffic&&p.buildTrafficLayer();null!=b.kml&&

    I keep the google style info in my theme options as a json formatted string, then use json_decode($string) to load that into the map_data_properties array

    Hope that makes sense/helps!

  5. macambulance
    Member
    Posted 8 months ago #

    note the styles:b.styles to line #2 in the js frameworks file, if you don't want to play spot-the-difference between the two js code samples

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic