• Resolved haije

    (@haije)


    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 :).

    https://www.ads-software.com/extend/plugins/pronamic-google-maps/

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Remco Tolsma

    (@remcotolsma)

    Thread Starter haije

    (@haije)

    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?

    Thread Starter haije

    (@haije)

    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 :).

    Thread Starter haije

    (@haije)

    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!!

    Thread Starter haije

    (@haije)

    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!

    Thread Starter haije

    (@haije)

    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.

    Thread Starter haije

    (@haije)

    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!! ??

    Plugin Author Remco Tolsma

    (@remcotolsma)

    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.

    Thread Starter haije

    (@haije)

    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!

    Thread Starter haije

    (@haije)

    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? ??

    Plugin Author Remco Tolsma

    (@remcotolsma)

    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.

    Thread Starter haije

    (@haije)

    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…?

    Plugin Author Remco Tolsma

    (@remcotolsma)

    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'] = 'https://google-maps-icons.googlecode.com/files/home.png';
    			break;
    		case 'project':
    			$marker_options['icon'] = 'https://google-maps-icons.googlecode.com/files/beach.png';
    			break;
    		default:
    			$marker_options['icon'] = 'https://google-maps-icons.googlecode.com/files/bar.png';
    			break;
    	}
    	// shadow - Shadow image
    	$marker_options['shadow']    = 'https://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.

    Thread Starter haije

    (@haije)

    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.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘[Plugin: Pronamic Google Maps] Custom mashup maps and custom markers’ is closed to new replies.