Joe Germuska
2009-Mar-04 20:09 UTC
[Mapstraction] Detect polyline relationship to map bounds?
I''m working on a mapstraction implementation modeled after the radius search feature. (http://mapstraction.com/demo-radius.php) I''d like to recognize when the user extends the radius beyond the visible edges of the map and adjust the zoom level. I''m not seeing how to test this when redrawing the circle. I thought maybe I wanted to use polylineCenterAndZoom() but that is zooming out to the whole earth even though I haven''t added any polylines besides the filtering circle. I have been digging around a bit, and I''m stumped. Any guidance would be greatly appreciated. Joe PS Mapstraction is incredible! -- Joe Germuska Joe at Germuska.com * http://blog.germuska.com "I felt so good I told the leader how to follow." -- Sly Stone -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20090304/e51126f4/attachment.htm>
Adam DuVander
2009-Mar-05 00:55 UTC
[Mapstraction] Detect polyline relationship to map bounds?
Hi Joe, I''m noticing the same issue with polylineCenterAndZoom zooming way out. Calling autoCenterAndZoom seems to work okay for me using the radius searching example. It only changes based on the markers. So, the circle may extend beyond the bounds of the map. Once it filters in a marker outside the bounds, the zoom level does change. That''s a solution for now, assuming that you''re doing something very similar to the radius searching example. --Adam --- Adam DuVander I like simple: http://adamduvander.com On Mar 4, 2009, at 12:09 PM, Joe Germuska wrote:> I''m working on a mapstraction implementation modeled after the > radius search feature. (http://mapstraction.com/demo-radius.php) > > I''d like to recognize when the user extends the radius beyond the > visible edges of the map and adjust the zoom level. I''m not seeing > how to test this when redrawing the circle. I thought maybe I > wanted to use polylineCenterAndZoom() but that is zooming out to the > whole earth even though I haven''t added any polylines besides the > filtering circle. > > I have been digging around a bit, and I''m stumped. Any guidance > would be greatly appreciated. > > Joe > > PS Mapstraction is incredible! > > -- > Joe Germuska > Joe at Germuska.com * http://blog.germuska.com > > "I felt so good I told the leader how to follow." > -- Sly Stone > > _______________________________________________ > Mapstraction mailing list > Mapstraction at lists.mapstraction.com > http://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com
Glad to see someone is using those radius functions. The function you want is polylineCenterAndZoom(). It takes a parameter called radius which is the radius you want it to extend by around the central point in KM. So if your radius is 5 miles, call mapstraction.polylineCenterAndZoom(mxn.fn.milesToKM(5)); If you still have issues, post a small code snippet and I''ll take a look later. Cheers, Rob 2009/3/5 Adam DuVander <mapstraction at duvander.com>> Hi Joe, > > I''m noticing the same issue with polylineCenterAndZoom zooming way out. > > Calling autoCenterAndZoom seems to work okay for me using the radius > searching example. It only changes based on the markers. So, the circle may > extend beyond the bounds of the map. Once it filters in a marker outside the > bounds, the zoom level does change. > > That''s a solution for now, assuming that you''re doing something very > similar to the radius searching example. > > --Adam > --- > Adam DuVander > I like simple: http://adamduvander.com > > > > On Mar 4, 2009, at 12:09 PM, Joe Germuska wrote: > > I''m working on a mapstraction implementation modeled after the radius >> search feature. (http://mapstraction.com/demo-radius.php) >> >> I''d like to recognize when the user extends the radius beyond the visible >> edges of the map and adjust the zoom level. I''m not seeing how to test this >> when redrawing the circle. I thought maybe I wanted to use >> polylineCenterAndZoom() but that is zooming out to the whole earth even >> though I haven''t added any polylines besides the filtering circle. >> >> I have been digging around a bit, and I''m stumped. Any guidance would be >> greatly appreciated. >> >> Joe >> >> PS Mapstraction is incredible! >> >> -- >> Joe Germuska >> Joe at Germuska.com * http://blog.germuska.com >> >> "I felt so good I told the leader how to follow." >> -- Sly Stone >> _______________________________________________ >> Mapstraction mailing list >> Mapstraction at lists.mapstraction.com >> http://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com >> > > _______________________________________________ > Mapstraction mailing list > Mapstraction at lists.mapstraction.com > http://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20090305/da084b33/attachment.htm>
Joe Germuska
2009-Mar-10 16:10 UTC
[Mapstraction] Detect polyline relationship to map bounds?
On Mar 5, 2009, at 5:34 AM, Rob wrote:> Glad to see someone is using those radius functions.It''s extremely cool!> The function you want is polylineCenterAndZoom(). > It takes a parameter called radius which is the radius you want it > to extend by around the central point in KM. > > So if your radius is 5 miles, call > mapstraction.polylineCenterAndZoom(mxn.fn.milesToKM(5));I know that Javascript error handling is not an exact science, but would it makes sense to throw an exception if the function is called without a radius? But now that that''s clarified... it still doesn''t do what I expected. Maybe it''s my expectations that are the problem? It''s kind of hard to extract any of my code, but here''s something that demonstrates what I''m not understanding. Go to http://mapstraction.com/demo-radius.php in a browser where you can interact in JS (Firebug, JS Shell, Safari Web Inspector) Enter this at a JS prompt: mapstraction.polylineCenterAndZoom(mxn.fn.milesToKM(1)) I thought it would zoom to roughly the size of the radius, but it doesn''t change at all. Or, to demonstrate the case I want to handle, slide the radius to the end (5). Then enter mapstraction.polylineCenterAndZoom(mxn.fn.milesToKM(5)) the result is larger than what I want. Now, I guess this is largely because the zoom levels are quantum, but experimentation shows that the above results in a zoom level of 10 when experimentally, I find that 11 would be a more "snug" fit. Is this just something one has to deal with based on the constraints of the mapping APIs and the math? Actually, my original question was meant to be "is there a function to tell me that my polyline has gone outside of the bounding box?", in which case I think I would just decrement the zoom level until that function returned false. Thanks, Joe -- Joe Germuska Joe at Germuska.com * http://blog.germuska.com "I felt so good I told the leader how to follow." -- Sly Stone -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20090310/236d59d1/attachment.htm>
Hi Joe, My mistake :) you should only pass in a radius if you need to add a futher distance around the visible polylines to show. This is to support zooming around a route radius (future planned functionality) which can be seen here: http://demo.evince-online.com/mapping/ (Select both the automatic switches to the right and change the slider) Anyway, for now, just pass in a 0 for it to zoom to the extents of all visible points and radii: mapstraction.polylineCenterAndZoom(0); I''ll look to add 0 as the default later on tonight if nothing is passed in. Cheers, Rob 2009/3/10 Joe Germuska <joe at germuska.com>> On Mar 5, 2009, at 5:34 AM, Rob wrote: > > Glad to see someone is using those radius functions. > > > It''s extremely cool! > > The function you want is polylineCenterAndZoom(). > It takes a parameter called radius which is the radius you want it to > extend by around the central point in KM. > > So if your radius is 5 miles, call > mapstraction.polylineCenterAndZoom(mxn.fn.milesToKM(5)); > > > I know that Javascript error handling is not an exact science, but would it > makes sense to throw an exception if the function is called without a > radius? > > But now that that''s clarified... it still doesn''t do what I expected. > Maybe it''s my expectations that are the problem? > > It''s kind of hard to extract any of my code, but here''s something that > demonstrates what I''m not understanding. Go to > http://mapstraction.com/demo-radius.php > in a browser where you can interact in JS (Firebug, JS Shell, Safari Web > Inspector) > > Enter this at a JS prompt: > mapstraction.polylineCenterAndZoom(mxn.fn.milesToKM(1)) > > I thought it would zoom to roughly the size of the radius, but it doesn''t > change at all. Or, to demonstrate the case I want to handle, slide the > radius to the end (5). Then enter > mapstraction.polylineCenterAndZoom(mxn.fn.milesToKM(5)) > > the result is larger than what I want. Now, I guess this is largely > because the zoom levels are quantum, but experimentation shows that the > above results in a zoom level of 10 when experimentally, I find that 11 > would be a more "snug" fit. > > Is this just something one has to deal with based on the constraints of the > mapping APIs and the math? > > Actually, my original question was meant to be "is there a function to tell > me that my polyline has gone outside of the bounding box?", in which case I > think I would just decrement the zoom level until that function returned > false. > > Thanks, > Joe > > -- > Joe Germuska > Joe at Germuska.com * http://blog.germuska.com > > "I felt so good I told the leader how to follow." > -- Sly Stone > > > _______________________________________________ > Mapstraction mailing list > Mapstraction at lists.mapstraction.com > http://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20090310/ee3eb4fe/attachment.htm>
Now fixed in SVN :) 2009/3/10 Rob <mapstraction at thegecko.org>> Hi Joe, > > My mistake :) > > you should only pass in a radius if you need to add a futher distance > around the visible polylines to show. This is to support zooming around a > route radius (future planned functionality) which can be seen here: > > http://demo.evince-online.com/mapping/ > (Select both the automatic switches to the right and change the slider) > > Anyway, for now, just pass in a 0 for it to zoom to the extents of all > visible points and radii: > > mapstraction.polylineCenterAndZoom(0); > > I''ll look to add 0 as the default later on tonight if nothing is passed in. > > Cheers, > > Rob > > 2009/3/10 Joe Germuska <joe at germuska.com> > >> On Mar 5, 2009, at 5:34 AM, Rob wrote: >> >> Glad to see someone is using those radius functions. >> >> >> It''s extremely cool! >> >> The function you want is polylineCenterAndZoom(). >> It takes a parameter called radius which is the radius you want it to >> extend by around the central point in KM. >> >> So if your radius is 5 miles, call >> mapstraction.polylineCenterAndZoom(mxn.fn.milesToKM(5)); >> >> >> I know that Javascript error handling is not an exact science, but would >> it makes sense to throw an exception if the function is called without a >> radius? >> >> But now that that''s clarified... it still doesn''t do what I expected. >> Maybe it''s my expectations that are the problem? >> >> It''s kind of hard to extract any of my code, but here''s something that >> demonstrates what I''m not understanding. Go to >> http://mapstraction.com/demo-radius.php >> in a browser where you can interact in JS (Firebug, JS Shell, Safari Web >> Inspector) >> >> Enter this at a JS prompt: >> mapstraction.polylineCenterAndZoom(mxn.fn.milesToKM(1)) >> >> I thought it would zoom to roughly the size of the radius, but it doesn''t >> change at all. Or, to demonstrate the case I want to handle, slide the >> radius to the end (5). Then enter >> mapstraction.polylineCenterAndZoom(mxn.fn.milesToKM(5)) >> >> the result is larger than what I want. Now, I guess this is largely >> because the zoom levels are quantum, but experimentation shows that the >> above results in a zoom level of 10 when experimentally, I find that 11 >> would be a more "snug" fit. >> >> Is this just something one has to deal with based on the constraints of >> the mapping APIs and the math? >> >> Actually, my original question was meant to be "is there a function to >> tell me that my polyline has gone outside of the bounding box?", in which >> case I think I would just decrement the zoom level until that function >> returned false. >> >> Thanks, >> Joe >> >> -- >> Joe Germuska >> Joe at Germuska.com * http://blog.germuska.com >> >> "I felt so good I told the leader how to follow." >> -- Sly Stone >> >> >> _______________________________________________ >> Mapstraction mailing list >> Mapstraction at lists.mapstraction.com >> http://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com >> >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20090310/8337ba94/attachment-0001.htm>