WordPress.org

Ready to get started?Download WordPress

Forums

Pronamic Google Maps
[resolved] Custom icons in static map? (5 posts)

  1. MattV
    Member
    Posted 1 year ago #

    Thanks for such a simple but powerful plugin.

    Can we use custom icons in static maps with this plugin?

    I´ve seen the code snippet to use custom icons in a mashup, but I can´t get it to work in a static map.

    This is what I´ve been using:

    if(function_exists('pronamic_google_maps')) {
      pronamic_google_maps(array(
        'width' => 290,
        'height' => 200,
        'static' => true,
        'map_options' => array(
          'mapTypeId' => 'map',
          'zoom' => 10
        ),
        'marker_options' => array(
          'icon' => '/path/to/map_icon.png'
        )
    ));
    }

    http://wordpress.org/extend/plugins/pronamic-google-maps/

  2. Remco Tolsma
    Member
    Plugin Author

    Posted 1 year ago #

    The following code is working for me:

    pronamic_google_maps(array(
    	'width' => 580 ,
    	'height' => 150 ,
    	'map_options' => array(
    		'minZoom' => 10 ,
    		'maxZoom' => 11 ,
    		'streetViewControl' => false
    	) ,
    	'marker_options' => array(
    		'icon' => 'http://google-maps-icons.googlecode.com/files/photo.png'
    	)
    ));

    Maybe the link to your icon is not correct? You could use the get_stylesheet_directory_uri() function for an absolute URL to your theme.

    if(function_exists('pronamic_google_maps')) {
      pronamic_google_maps(array(
        'width' => 290,
        'height' => 200,
        'static' => true,
        'map_options' => array(
          'mapTypeId' => 'map',
          'zoom' => 10
        ),
        'marker_options' => array(
          'icon' => stylesheet_directory_uri() . '/path/to/map_icon.png'
        )
    ));
    }
  3. MattV
    Member
    Posted 1 year ago #

    Your first code snippet works, but only for dynamic Google Maps. When I add 'static' => true the custom icon is not shown anymore.

    I had a look at the map image URL and it seems that the icon path is not passed to the markers parameter. Instead it shows the lat/long as value of the markers parameter.

    My map:

    http://maps.google.com/maps/api/staticmap?center=36.312416951469%2C126.51132056484&zoom=10&size=580x150&maptype=roadmap&sensor=false&markers=36.312416951469%2C126.51132056484

    Working example of static map with custom icons:

    http://maps.googleapis.com/maps/api/staticmap?size=480x480&markers=%20icon:http://chart.apis.google.com/chart?chst=d_map_pin_icon%26chld=cafe%257C996600%7C%20224+West+20th+Street+NY%7C75+9th+Ave+NY%7C700+E+9th+St+NY&sensor=true
  4. Remco Tolsma
    Member
    Plugin Author

    Posted 1 year ago #

    Sorry i misunderstood, an custom icon on an static map was not supported. In the next release you can alse use an custom icon an static maps.

    https://github.com/pronamic/wp-pronamic-google-maps/commit/819e9b8a3f2be93b73feb3993d470da1460a0264

  5. MattV
    Member
    Posted 1 year ago #

    That´s great! Thanks for your support.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.