BradSiegfried

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
    Posts
  • in reply to: How to read and save map view (lat/lng/zoom) #15683
    BradSiegfried
    Participant

    Hi Chris,

    I was able to learn enough to get and save the map information to user meta successfully. Thank you!

    My last hurdle is getting the actual map to redisplay via AJAX. When I initially create and display the map in my shortcode, I do something along the lines of
    $result = $mymap->display();
    return($result);

    This works fine as anticipated on the initial display. However, when the user subsequently changes a map setting and initiates the AJAX request I am having trouble returning the new $result. My AJAX callback function calls my shortcode function directly and appears to receive the map display returned as above. The AJAX callback function then returns the map display along with some other data via JSON to my jQuery success function like this:

    $mydata = json_encode($mydata);
    header(“Content-type: application/json”);
    wp_die($mydata);

    I then try to replace the old map with the new map like this:

    success: function(data) {
    jQuery(“#mymap”).html(data.mymap);

    This is where I see the problem. The resulting map is blank. mapp0_layout is there along with associated child divs, but the mapp0 map canvas is empty.

    Can you suggest where I may be going wrong?

    Brad

    in reply to: Mashup shortcode to show by event date #12726
    BradSiegfried
    Participant

    Maybe a typo on “&meta_comapare”?

    in reply to: How to specify excerpt for marker_body? #11799
    BradSiegfried
    Participant

    Thanks, Chris.  “mashupBody” => “post” worked great.  I had looked but couldn’t find the marker_body syntax in the documentation.  Thanks for the quick helping hand.

    I’ll explore the filter once I nail down the functionality and start optimizing for speed.

    in reply to: Using map as input device for other field? #11254
    BradSiegfried
    Participant

    Thank you, Gertkok, for sharing and explaining.  Your example will be an excellent learning opportunity for me.

    in reply to: Using map as input device for other field? #11246
    BradSiegfried
    Participant

    I use both Formidable and MapPress and would be interested in doing exactly what Gertkok describes.

    Gertkok, please post back and let me know how your plan works out.  Any pointers would be appreciated.

    Thanks.

    Brad

    in reply to: Mashup with date filter #11245
    BradSiegfried
    Participant

    I think you’ll need to write some PHP since you want a date range calculated based on the current date.  When I need to write shortcodes, I keep them in a utility plugin so I don’t have to worry about theme changes.  You can learn a lot by looking at the plugins that other people have written.  See http://codex.wordpress.org/Writing_a_Plugin for some help getting started.

    You might do something along the lines of the code below to filter by date:

    global $my_datefrom, $my_dateto;

    // Create a new filtering function that will add our where clause to the query
    function my_filter_where($where = ”) {
    global $my_datefrom, $my_dateto;
    if ($my_datefrom) $where .= ” AND post_date >= ‘” . $my_datefrom;
    if ($my_dateto) $where .= “‘ AND post_date <= ‘” . $my_dateto . “‘”; else $where .= “‘”;
    return $where;
    }

    // [my_querymap my_datefrom=”2012-07-01″ my_dateto=”2012-12-02″ ]
    function my_querymap($atts, $content = null) {

    global $my_datefrom, $my_dateto;

    extract( shortcode_atts( array(
    ‘my_datefrom’ => date(‘Y-m-d’, strtotime(‘-30 days’)),
    ‘my_dateto’ => date(‘Y-m-d’),
    ), $atts ) );
    $result = “”;

    // Do the query to return desired posts for my_datefrom to my_dateto:
    $my_query_string = array(‘category_name’ => ‘my_categoryname’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘posts_per_page’ => ‘-1’);
    // Add a filter that will add our where clause to the query
    add_filter(‘posts_where’, ‘my_filter_where’);
    $my_query = new WP_Query( $my_query_string );
    $my_news = $my_query->get_posts();
    remove_filter(‘posts_where’, ‘my_filter_where’);

    … more code would go here to create the map from the query results …

     

    I hope that helps.  If not, maybe Chris can suggest an easier way to do what you want.

    Brad

    in reply to: mapLinks in individual maps? #11132
    BradSiegfried
    Participant

    Thanks, Chris.  That worked like a charm once I remembered the commandment about not pasting curly quotes…

    Brad

    BradSiegfried
    Participant

    I updated to MapPress 2.39.0.  The poilist now displays as I wanted it to.

    BradSiegfried
    Participant

    An example of maps with poilist sorted by proximity to map center is at http://dev-wilmington.crimeboard.org/units/. The tooltip on the map does show the distance from the map center, but I’d like to show that in the poilist as well.
    $poi->title = “($slc_distance miles) $poi->title”;
    The above code does not change the poilist display as I thought it would, just the tooltip on the map.

     

    BradSiegfried
    Participant

    Hi Chris,

    I am calculating distance of each POI from the map center and would like to append that information to the Location that is shown in the poilist.  I also plan to use that value to filter results.  Can you tell me which object or array value I need to update in reference to your code sample above (#10981)?

    Also, is it possible to exclude some points from the poilist but leave them in the map display?

    See http://sgowtham.net/blog/2009/08/04/php-calculating-distance-between-two-locations-given-their-gps-coordinates/ for the distance calculation that I’m using.

    Thanks.

    Brad

    in reply to: Mashup with date filter #11029
    BradSiegfried
    Participant
    BradSiegfried
    Participant

    Found it at http://mappresspro.com/mappress-beta#toc-settings.

    Changed to the required “center” array format instead of “center_lat” and “center_lng”:

    $mymap = new Mappress_Map(array(“width” => 300, “height” => 200, “zoom” => 13, “posts_per_page”=> -1, “overviewmapcontrol” => false, “maptypecontrol” =>false, “marker_body” => “none”, “marker_link” => true, “marker_title” => “post”, “poilist” => false, “center” => array(“lat” => $cblat, “lng” => $cblng)));

    It works!

    BradSiegfried
    Participant

    Hi Chris,

    I have this almost working.  However, the resulting map center seems not to be as specified in the code.  If I manually move the displayed map, I can see my POIs, but the initial map center appears to be around 5 miles south of the desired coordinates, resulting in 39.601191,-75.605221 instead of the requested 39.749031, -75.57013.  There are no POIs in view on the initial map display.

    You can see the results at http://dev-wilmington.crimeboard.org/units/182f/.

    Code snippet:

    function cbquerymap($atts, $content = null) {
    global $cbdatefrom, $cbdateto;
    extract( shortcode_atts( array(
    ‘cbdatefrom’ => date(‘Y-m-d’, strtotime(‘-30 days’)),
    ‘cbdateto’ => date(‘Y-m-d’),
    ‘cblat’=>”39.749031″,
    ‘cblng’=>”-75.57013″,
    ), $atts ) );
    $result = “”;

    … more code happens …

    // Return the map display;
    $mymap = new Mappress_Map(array(“width” => 300, “height” => 200, “zoom” => 13, “posts_per_page”=> -1, “overviewmapcontrol” => false, “maptypecontrol” =>false, “marker_body” => “none”, “marker_link” => true, “marker_title” => “post”, “poilist” => false, “center_lat” => $cblat, “center_lng” => $cblng));
    $mymap->pois = $pois;
    $result = $mymap->display();

    $result .= “lat= $cblat, lng= $cblng”;
    return ($result);

    I see that there is one outlier POI much farther south than the rest.  It appears that the map center is being calculated rather than taken from the “center_lat” and “center_lng” values I specified.  Can you point me toward a solution?  Your login credentials are the same as before at http://dev-wilmington.crimeboard.org if you want to take a closer look.  See the “xper” plugin.

    Thanks.

    Brad

    BradSiegfried
    Participant

    Thanks, Chris.  I’ll work on that.

    BradSiegfried
    Participant

    Thanks for the quick response, Chris.  I’ll experiment with the orderby.  At worst case that should let me get all units and all news, then just leave the zoom level to filter the view.

    It sounds like PHP will be the best option in the long run.  If I were to use PHP to build the mashup, would I do separate queries, one for units and one for news, then concatenate the results?  I looked through http://mappresspro.com/mappress-documentation#toc-mashups but didn’t see an example of building a mashup with PHP.  Could you link me to some reading material on this?

    Great news on the proximity search.  I’m hoping that once I get the PHP option mashup working, the proximity search will drop in there nicely.

    Thanks for your help.

    Brad

    PS. I think my earlier submission problem was that I failed to enter a title when I first submitted.

Viewing 15 posts - 1 through 15 (of 25 total)