WordPress.org

Forums

ImageMapper
Manually editing area coordinates. Is it possible? (5 posts)

  1. cebollo3
    Member
    Posted 2 years ago #

    Is there a way to manually edit the coordinates of the vertices that comprise each map area?
    I'm trying to keep some vertices aligned (for example, to keep the angles of a squared shape straight).
    This is no bug; I'm just asking if these feature exists or if there is a quick hack to get around it.

    By the way, this plugin does exactly what I need. If it was possible to tweak the areas, this plugin would be perfect.

    Thank you in advance.

    http://wordpress.org/extend/plugins/imagemapper/

  2. Spike
    Member
    Plugin Author

    Posted 2 years ago #

    Hi,

    Currently there isn't any existing feature for this. But if you're familiar with WordPress development you can find them using following function:

    get_post_meta([POST_ID], 'coords')

    The coordinates are saved in post_meta in HTML image map coordinate format ("x1, y1, x2, y2, x3, y3" and so on).

    If you are familiar with plugin development, it shouldn't be too hard to write a plugin which allows you to do this.

    And sorry for a late answer. :<

  3. kmg1016
    Member
    Posted 2 years ago #

    Spike, thanks for producing this plugin, I think it can be quite useful.

    Unfortunately, I don't actually understand the get_post_meta instruction above. Where are the area coordinates stored by the plugin, and is it possible (if the nomenclature is accurately replicated) to simply input a list of coordinates as "areas" so that the map will work properly (i.e. in the plugin editor)?

    Thanks for your help!

  4. thorsten23
    Member
    Posted 1 year ago #

    Although your post is quite old, maybe this helps:
    If you want to achieve proper rectangles, you could add the following code into image_mapper_admin_script.js in Function AddArea() just after the 'if(Coords.length < 3) {...}' command.

    Hope this helps,
    Thorsten

    [ Moderator note: please wrap code in backticks or use the code button. ]

    if (Coords.length == 4 && confirm('Do you want the coordinates to be adjusted as rectangles ?')) {
    
    		topp = 10000;
    		left = 10000;
    		right = -100;
    		bottom = -100;
    
    		for (var i=0; i<Coords.length; i++) {
    
    			if (Coords[i].x > right)
    				right = Coords[i].x;
    
    			if (Coords[i].x < left)
    				left = Coords[i].x;
    
    			if (Coords[i].y > bottom)
    				bottom = Coords[i].y;
    
    			if (Coords[i].y < topp)
    				topp = Coords[i].y
    
    		}
    
    		Coords[0].x = left;
    		Coords[0].y = bottom;
    
    		Coords[1].x = left;
    		Coords[1].y = topp;
    
    		Coords[2].x = right;
    		Coords[2].y = topp;
    
    		Coords[3].x = right;
    		Coords[3].y = bottom;
    
    	}
  5. kmg1016
    Member
    Posted 1 year ago #

    Hi Thorsten, do you know what the difference would be if using polygons as opposed to rectangles?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • ImageMapper
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.