[ka-Map-users] Perl back end and other features

Steve Lime steve.lime at dnr.state.mn.us
Mon May 30 17:03:44 EDT 2005


Actually you can draw arbitrary lines with javascript. Check out http://www.walterzorn.com/jsgraphics/jsgraphics_e.htm. Works ok for relatively simple features. I'm using it for the box drawing and measure tool at www.dnr.state.mn.us/maps/landview.html...

One other thing is that a guy by the name of Richard Bennett will be at MUM3 and he's build some really great javascript for digitizing polygons, lines and so forth. His stuff is more for input (via a mouse) at the moment but should be usable for general drawing too. He's seen the link above and thought he could do better. Samples I've seen look nice.

Steve

>>> Paul Spencer <pspencer at dmsolutions.ca> 05/30/05 11:35 AM >>>
Stephen ... more comments inline :)

Stephen Woodbridge wrote:
> Paul Spencer wrote:
> 
> Comments in line below.
> 
>> Hi Stephen,
>>
>> this sounds great! comments inline ...
>>
>> Stephen Woodbridge wrote:
>>
>>> Hi all,
>>>
>>> I have been writing a perl backend for ka-map and have it pretty 
>>> function at this point. I have integrated have also add a few 
>>> enhancements like:
>>>
>>> 1) the ability to define a [long, lat, scale] to the mapfile 
>>> structure after the image type in the array and made init.cgi 
>>> position the map to that location and scale when the map is initialized.
>>
>>
>>
>> great addition ... did you also make it so these could be passed to 
>> the init script so that the calling application could affect the start 
>> up without requiring changes on the server side?
> 
> 
> Not exactly, but it would be trivial to make the change and I will 
> probably do it.
> 
> [snip]
> 
>>> I have a few questions:
>>>
>>> 1. When I position the map after geocoding a location I set the 
>>> location to cX, cY instead of computing these values as the center of 
>>> the extents, but this is not centered on the viewport. I think this 
>>> is because of the clamp to a tile is causing it to be shifted. How 
>>> can I get it to center? Can I send some additional javascript values 
>>> to cause it to scroll/slide after it is loaded so it is centered?
>>
>>
>>
>> I really need to wrap my head around the correct logic to center the 
>> map correctly based on the initial extents or using the requested 
>> extents in your example.  I just haven't had the time to work it out.
>>
>> You can scroll/slide by a number of pixels ... if you are using the 
>> cvs version, the code would be called using kaMap_moveBy x, y ) or 
>> kaMap_slideBy x, y ) ... these will be made part of the kaMap object 
>> at some point but right now they are stand-alone functions
> 
> 
> Yeah, I figured I might be able to do something like that. When you work 
> out the logic for the position stuff, please put it in a document. The 
> code code is easy to work with, but the math is not obvious. For example 
> does the client work totally in pixel space? (I think this is true).

documentation is not my strong point ;)

The client does work entirely in pixel space. The math is straight 
forward because all you need is a scale value to convert pixels to 
geographic coordinates.  0,0 in pixel space is 0,0 in geographic space. 
  One complicating factor was introduced, xOrigin and yOrigin so the 
pixel coordinates would not get too big to be represented in the css 
style object.  But in general, the geo coordinate of any given pixel 
location is (pixel + origin) * cellsize ... similarly something can be 
plotted at a geo location by geo / cellsize - origin.  Note that the 
origin can and does change (only on zoom right now, but in the future it 
may change on pan too)

> 
>>> 2. The Next thing I would like to support is a route overlay like 
>>> google. Have you thought about doing this? I can get the route 
>>> polyline loaded into a javascript array, how do I get the array 
>>> displayed as a polyline on a layer? How do I scale the coordinates 
>>> for the route to the current zoom scale? I'm not asking for code (but 
>>> I would take it :), more for the your thoughts on how to best 
>>> approach this?
>>
>>
>>
>> Google's approach seems to be a hybrid depending on browser.  In 
>> mozilla -based browsers, they display a huge transparent image ... 
>> actually an alpha'd image I think ...
>>
>> this guy has an explanation of how google does it:
>>
>> http://jgwebber.blogspot.com/2005/02/mapping-google.html
> 
> 
> I've seen this, it is a lot of information to assimilate. I'll probably 
> be reading it some more.
> 
>> For me, I would prefer just to use the transparent gif approach I 
>> think and pin the image on the map.  I think this should be quite 
>> easily done if you can calculate the top/left corner of the image in 
>> geo-coords and convert to pixel coords then create a new image object 
>> (document.createElement('img')), set it up appropriately and add it to 
>> the 'theInsideLayer' div with position: absolute and the correct 
>> top/left position.
>>
>> Note that the top/left will need to be adjusted by the xOrigin and 
>> yOrigin and the image will have to be redone completely when zooming
>>
>> Alternately, an entire new layer could be added and the route polyline 
>> be drawn by mapserver as a layer which would then be tiled in the same 
>> way as the other map layers ... only this one should be cached 
>> differently and managed slightly differently on the client side
> 
> 
> I had I thought about these but did not like them as options for the 
> following reasons:
> 
> 1. for routes the cover small spatial areas creating an image is 
> probably ok, but it would require generating an image that it extremely 
> large at the most zoomed in scale, so it is not a scalable solution, I 
> think.
> 
> 2. the route image could be tiled, but his is not a good solution in a 
> production environment when you need to deal 10-100K routes a day
> 
> 3. 1. and 2. are compounded by the need to do this at multiple scales.
> 
> So, I am thinking that a client side solution is probably the way to go, 
> but Java script is not my strong suit. The idea(s) that I am toying with 
> are.
> 
> Pass the route polyline as a javascript array and pass the cellsize for 
> the current zoom, then render the polygon in the client on its own 
> layer. This would require creating a layer and aligning it with the map 
> so that the polyline array can be looped through and drawn. On a zoom, 
> you would return the new cellsize, clear the layer and redraw the polyline.
> 
> The benefit is that the route would be cached on the browser, and it 
> would off load the servers. If we add this kind of support, then the 
> same math can be applied to POI, markers, etc that anyone would like to 
> place on the map. You would just pass an array of 
> [x,y,image,label,description] objects and then place the image and 
> optional label at x,y and get fancy with a mouseover the image or label 
> would cause a dhtml popup with the description in it.

the problem with this is that you can't actually draw arbitrary lines in 
javascript ... you would need an svg plugin or something.

Points are good, lines are a problem.

> 
>>> 3. OK, while I'm asking has anyone, done anything with putting 
>>> markers on a layer? with mouseovers on the markers? etc.
>>
>>
>>
>> thinking about it ... same approach as above.  I will likely add the 
>> capability to the kaMap API at some point, unless someone else does it 
>> first.
> 
> 
> See above. As I said, Javascript is not my strong suit so please don't 
> wait on me for this ;)

:)

> 
> -Steve
> 
>>> This is very nice work Paul! I had started to do this myself when you 
>>> announced it, so I'm happy to work on it an make some contribution 
>>> instead. I will get a URL posted shortly.
>>>
>>
>> thanks, we're looking forward to it.
>>
>> Paul
>>
>>> -Steve W.
>>>  http://imaptools.com
>>>  http://where2getit.com
>>> _______________________________________________
>>> ka-Map-users mailing list
>>> ka-Map-users at lists.maptools.org
>>> http://lists.maptools.org/mailman/listinfo/ka-map-users
>>>
>>
> 
> 

-- 
+-----------------------------------------------------------------+
|Paul Spencer                           pspencer at dmsolutions.ca   |
+-----------------------------------------------------------------+
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
+-----------------------------------------------------------------+
_______________________________________________
ka-Map-users mailing list
ka-Map-users at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/ka-map-users




More information about the ka-Map-users mailing list