[ka-Map-users] Novice on KaMap - how to plot a point on Kamap?

The Bun rosario.carbone at ipl.com
Mon Nov 12 04:50:50 EST 2007


You mentioned PHP then I assume you want to add points server side. As far as
I know, I am new myself to kaMap, you can do it adding the points in the
mapfile itself but it is not very popular, there are many techniques I'll
tell you what I have done in my prototype, I create dinamically an xml file
that contains the 
coordinates of the points I want to add, but you can have a database, a file
or anything else you need as data source, anyway I have done this way with
my xml ( the bolded part is the part you actually really need ):

tile.php:

   // Create a DOM object
   $doc = new DOMDocument();
   // Load the xml file
   $doc->load("points.xml");
   // Get the first "point" element
   $points = $doc->getElementsByTagName("point");
   // Parse all the "point" elements
   foreach( $points as $point )
   {
         // Get the coordinates from the "point" element
         $longitudes = $point->getElementsByTagName( "longitude" );
         $longitude = $longitudes->item(0)->nodeValue;
         $latitudes = $point->getElementsByTagName( "latitude" );
         $latitude = $latitudes->item(0)->nodeValue;
         // Get the layer from the map
         $layer = $oMap->getLayerByName("selpoint");
         // Add the point to the map
         add_point_to_layer($layer, $longitude, $latitude);   }

Just for your information my where "points.xml" is structured this way:

<?xml version="1.0" encoding="iso-8859-1"?> 
<points>
    <point>  
        <longitude>-476249.61</longitude>  
        <latitude>1543401.94</latitude>  
    </point>
    <point>  
        <longitude>-474133.08</longitude>  
        <latitude>922866.17</latitude>  
    </point>
</points>

I was nearly forgotting, I needed the layer "selpoint" predefined in
mapfile:

LAYER 
   NAME selpoint
   TYPE POINT
   STATUS ON
   CLASS
       NAME "selpoint"
       SYMBOL 2
       COLOR 255 0 0 
       LABEL
           TYPE bitmap
       END
       STYLE
         SYMBOL 2
         SIZE 20
         COLOR 255 0 0 
       END
   END
   TOLERANCE 5
END 

I couldn't find a complete dynamic working example anywhere, in fact I
wanted to create a layer in the code, in memory, and use that dynamic layer
for adding my points all in the in the PHP code but I failed.

Anyway I think much more interesting in my opinion is adding points client
side, this is all in JavaScript. This I used in my prototype, it is hard
coded but it is just as example:

    // Prepare the array of images    
    var imgArray = new Array();
    imgArray[0] = document.createElement( 'img' );
    imgArray[0].src = 'images/kamap.gif';
    imgArray[1] = document.createElement( 'img' );
    imgArray[1].src = 'images/kamap.gif';
    // Add the first object	
    var lon = -476249.61;
    var lat = 1543401.94;    
    myKaMap.addObjectGeo( myKaMap.createDrawingCanvas( 500 ), lon, lat,
imgArray[0]);
    // Add the second object
    lon = -474133.08;
    lat = 922866.17;        
    myKaMap.addObjectGeo( myKaMap.createDrawingCanvas( 500 ), lon, lat,
imgArray[1]);

Regards
Rosario Carbone


pjqcf wrote:
> 
> All,
>    
>   I have just installed Kamap on my machine and was able to get customized
> shapefile loaded on it. Now the next obvious thing is to plot a point on
> the top of my map that is showing from the map file.
>    
>   My understanding is: This is done using PHP coding. But I don't have any
> starting point.
>    
>   It would be really helpful if someone could help me understand how to do
> this?
>    
>   Thanks in advance..
>    
>   Puneet
> 
>  __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> _______________________________________________
> ka-Map-users mailing list
> ka-Map-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/ka-map-users
> 
> 

-- 
View this message in context: http://www.nabble.com/Novice-on-KaMap---how-to-plot-a-point-on-Kamap--tf4789050.html#a13702689
Sent from the ka-map-users mailing list archive at Nabble.com.



More information about the ka-Map-users mailing list