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

Puneet Juneja pjuneja01 at yahoo.com
Mon Nov 12 08:18:49 EST 2007


Hey Rosairo,
   
  Thanks for a great answer. In one mail I am now very clear with the functioning of Kamap. But I still need your help so as to learn where to put these code. 
   
  I tried copying the php code in tile.php and created an xml file named points.xml in the directory where my tile.php is present. It didn't work. One thing, where is the function 'add_point_to_layer' defined? I will try once again by cleaning the Kachace. Meanwhile, please let me know if I am doing something wrong.
   
  Also, I liked the idea of using Javascript but again I am confused that which file should contain this Javascript? Again, is there any .js file within Kamap directory having 'addObjectGeo' function?
   
  Thanks for sparing time in answering my questions..
   
   
  Puneet


The Bun <rosario.carbone at ipl.com> wrote:
  
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:






-476249.61 
1543401.94 




-474133.08 
922866.17 





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.

_______________________________________________
ka-Map-users mailing list
ka-Map-users at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/ka-map-users


 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/ka-map-users/attachments/20071112/13ac8b79/attachment-0001.html


More information about the ka-Map-users mailing list