WordPress.org

Ready to get started?Download WordPress

Forums

Pronamic Google Maps
[resolved] Custom mashup maps and custom markers (15 posts)

  1. haije
    Member
    Posted 1 year ago #

    Hi,

    thanks for a great plugin, this was just what I was searching for, I think! :) But I have few questions though to finish my maps like I need them.

    Let's say I have two custom post types I want to have maps.

    How do I define a custom marker for different custom post types?

    I also need 3 different mashup maps:

    1. map for custom post type "A" with custom marker for the posts
    2. map for custom post type "B" with custom marker
    3. map for both/all the custom post types (those I have chosen in settings), and the markers should be the same custom markers, meaning "A" marker for custom posts type "A", "B"-marker for custom posts type B etc.

    Can this be done and how would I do it? I am sure it is not very difficult? Thanks a lot in advance, this is really important to me :).

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

  2. Remco Tolsma
    Member
    Plugin Author

    Posted 1 year ago #

  3. haije
    Member
    Posted 1 year ago #

    Thanks a lot for your amazingly quick answer, I highly appreciate!! :)

    So I put the code to my theme's functions.php -file, is it so? Of course never to touch the plugin's code files, so that I can do updates to the plugin?

  4. haije
    Member
    Posted 1 year ago #

    How are the shortcodes like, I need three different shortcodes to get the examples I mentioned?

    I am not sure did you understand the 3rd map like I ment: there should be two types of markers, one for custom post type A and one for custom post type B. In the example 3. there is only one marker url now?

    Thanks :).

  5. haije
    Member
    Posted 1 year ago #

    In your plugin page you say "You should add some code to you templates to add the Google Map".

    Please, tell me, where should I put these codes? In which templates/files?

    Thanks!!

  6. haije
    Member
    Posted 1 year ago #

    Sorry for posting this much, but I want to figure this out.

    My Headway-theme's function.php looks like this:


    <?php
    /**
    * Starts Headway
    *
    * @package Headway
    * @author Clay Griffiths
    */

    /* Prevent direct access to this file */
    if ( !defined('WP_CONTENT_DIR') )
    die('Please do not access this file directly.');

    /* Make sure PHP 5.2 or newer is installed and WordPress 3.2 or newer is installed. */
    require_once get_template_directory() . '/library/common/compatibility-checks.php';

    /* Load Headway! */
    require_once get_template_directory() . '/library/common/functions.php';
    require_once get_template_directory() . '/library/common/application.php';

    Headway::init();

    I tried to put the codes there, but it results with errors.

    How should I add the codes in the function. php?

    Thanks!

  7. haije
    Member
    Posted 1 year ago #

    Ok, I created a child theme and added the code there, it basically works. Have to do some testing, and maybe ask still something more.

  8. haije
    Member
    Posted 1 year ago #

    Ok, now I have tested it. Not working like I would need it to work.

    I use shortcode to add a single persons map to single-post (post type = client), so that I can define that particular map's size and place. Works fine, but I need to change the marker image. And I use the shortcode for a mashup map in "client" listing page, and the maps includes all the "clients", works fine, but I need to change the marker image.

    No I added some code to the functions.php resulting that now I have both the original shortcoded (at right place, right size) map with the default marker, and a new map, in totally wrong place with the correct marker. And the new map that the functions.php create comes automatically to _every_ page where the custom post type is used, and that is not the way it should me in my case.

    So my (hopefully final) QUESTION is:

    1. How can I define one or more post types and their markers in SHORTCODE?
    Or define only the marker in the functions php, but decide with the SHORTCODE where and when the and if, the map is shown.

    I hope I could make my situation clear, I am not a programmer and not native English speaker. Thanks in advance!! :)

  9. Remco Tolsma
    Member
    Plugin Author

    Posted 1 year ago #

    I've tried to achieve this myself, but unfortunately this is currently not possible. We did however some adjustments in the plugin so this will be possible in the future:

    https://github.com/pronamic/wp-pronamic-google-maps/commit/97df45522a74e54edce681946ccedf7ca1445552

    You could download the development version of our plugin so you can use this latest adjustment:

    https://github.com/pronamic/wp-pronamic-google-maps
    https://github.com/pronamic/wp-pronamic-google-maps/zipball/master

    The code you could add to your (child) theme functions file:

    https://github.com/pronamic/wp-pronamic-google-maps/blob/master/examples/map-filter-marker-options.php

    This snippet wil also adjust the marker options of an Google Maps added by an shortcode.

    We hope to launch a new version of our plugin by the end of the month.

  10. haije
    Member
    Posted 1 year ago #

    Hi Remco,

    thanks a lot! I downloaded the development version and it is working fine. Sorry, but I did not understand, how can I "adjust the marker options added by an shortcode"? Could you give me an example of a shortcode, where I can define the marker(s) icons used?

    I am very glad if you are going to launch a new version where the functions I described (I am sure there is a big common need for them) are included. If so, your solution is exactly the one I need for my site project!! :):) Thanks in advance!

  11. haije
    Member
    Posted 1 year ago #

    PS. So in the coming new shortcode you are going to do, the admin (me) could use what ever markers she/he likes to have in different pages/posts, even with the same custom post type. So the custom post type(s) and the cursor (to be used in that particular post/page)is defined in the shortcode, not in functions.php? So there would NOT be any common rule "custom post type A = this marker image", but it is defined always in the shortcode. This way it would be very agile and versatile.

    Is this what your are going to do? :)

  12. Remco Tolsma
    Member
    Plugin Author

    Posted 1 year ago #

    Unfortunately that is not what we are going to do. We have adjusted the plugin so you can adjust the marker options through an filter function.

    https://github.com/pronamic/wp-pronamic-google-maps/blob/master/examples/map-filter-marker-options.php

    For now it will not be possible to adjust the marker options through an shortcode argument.

  13. haije
    Member
    Posted 1 year ago #

    Sorry, but I don't understand the new filter function?

    How do I specify the custom post type to a marker? Now there is only one marker image in the filter?

    Why are you not going to do the option I suggested? I think it is a very good idea and would broaden the use of your plugin greatly. There are lots of other Map plugins that allow many options in shortocdes, so why not yours? But I have not found anything similar enough with yours, because you have everything else I need in a very usable way. The only thing I need is to be able to define the markers by custom post type in shortcode. Is it very difficult to do...?

  14. Remco Tolsma
    Member
    Plugin Author

    Posted 1 year ago #

    How do I specify the custom post type to a marker? Now there is only one marker image in the filter?

    That's correct, but an developer can extend this, for example:

    /**
     * Filter snippet
     *
     * @see https://developers.google.com/maps/documentation/javascript/reference#MarkerOptions
     */
    function prefix_pronamic_google_maps_marker_options( $marker_options ) {
    	// icon - Icon for the foreground
    	switch( get_post_typ() ) {
    		case 'post':
    			$marker_options['icon'] = 'http://google-maps-icons.googlecode.com/files/home.png';
    			break;
    		case 'project':
    			$marker_options['icon'] = 'http://google-maps-icons.googlecode.com/files/beach.png';
    			break;
    		default:
    			$marker_options['icon'] = 'http://google-maps-icons.googlecode.com/files/bar.png';
    			break;
    	}
    	// shadow - Shadow image
    	$marker_options['shadow']    = 'http://google-maps-icons.googlecode.com/files/shadow.png';
    	// draggable -  	If true, the marker can be dragged. Default value is false.
    	$marker_options['draggable'] = true;
    
    	return $marker_options;
    }
    
    add_filter( 'pronamic_google_maps_marker_options', 'prefix_pronamic_google_maps_marker_options' );

    Why are you not going to do the option I suggested? I think it is a very good idea and would broaden the use of your plugin greatly. There are lots of other Map plugins that allow many options in shortocdes, so why not yours? But I have not found anything similar enough with yours, because you have everything else I need in a very usable way. The only thing I need is to be able to define the markers by custom post type in shortcode. Is it very difficult to do...?

    It's not difficult but we don't just add new features. You are the first who requested this feature. If we get similar request from other users we will consider adding this feature.

  15. haije
    Member
    Posted 1 year ago #

    Hi, thanks for the answer and for the code. I added the code to the functions.php, but it does not affect the map created with the shortcode for some reason? I corrected this line (the missing "e" in "type"):
    switch( get_post_typ() ) { -->
    switch( get_post_type() ) {

    I am surprised if I am the only one who thinks my suggestion would be great and also very necessary feature. Well, maybe I'll have to hire somebody to some modification to the code, I am not a programmer myself :(. I just thought also there are lots of people running a WP site that do not want to modify code, but would like to use simple shortcodes instead.

    Thanks for your help.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic