[mapguide-users] Mapguide maps using openlayers

Rodolfo Moreno rmoreno at voxiva.com
Wed Nov 19 16:53:51 EST 2008


Thanks Kenneth, finally I could fix it.
The problem was that style for the "map" div is not being placed suitable
and thus the map was not displayed. 

It happenned because my aspx page had the XHTML doc type at start of the
page.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

XHTML hopes that the styles to be linked to other CSS file. So I removed
this line and the example is working.

Regards,



Kenneth Skovhede, GEOGRAF A/S wrote:
> 
> Alright, that looks odd.
> It seems that the outermost div (named olMap) is hidden for some reason.
> have you tried to manually set the size and position for the div?
> like: <div id="olMap" style="display: block; position: absolute; top: 
> 0px; left: 0px; width: 500px; height: 500px">
> 
> The trace shows that the image is 300x300 but placed at -145 and -222 
> wich means that at most 155x78 pixels would be visible, wich is very
> weird.
> 
> Regards, Kenneth Skovhede, GEOGRAF A/S
> 
> 
> 
> Rodolfo Moreno skrev:
>> Kenneth,
>> In debug mode the init function is being used. 
>> In order to know whether mapguide server is requested I was seeing the
>> HTML 
>> firebug tab (see image attached) and it's possible see the image that
>> mapguide server has sent.
>>
>> Zac,
>> There is nothing in the firebug console tab
>>
>> maybe the image attached could be a clue what the viewer, in this case
>> open
>> layers is failing.
>> Regards,
>>
>>
>> zspitzer wrote:
>>   
>>> anything in the firebug console tab?
>>>
>>> On Wed, Nov 19, 2008 at 2:41 AM, Kenneth Skovhede, GEOGRAF A/S
>>> <ks at geograf.dk> wrote:
>>>     
>>>> The Firebug shows that you newer send a request to the MapGuide server.
>>>> Is there something missing, or are you never calling the init()
>>>> function?
>>>>
>>>> Regards, Kenneth Skovhede, GEOGRAF A/S
>>>>
>>>>
>>>> Rodolfo Moreno skrev:
>>>>
>>>> Hi Kenneth,
>>>> Here is the javascript code. It's similar to the posted in the wiki
>>>> (http://trac.osgeo.org/mapguide/attachment/wiki/CodeSamples/JavaScript/OpenlayersExample/sheboygan.php)
>>>>
>>>> <script type="text/javascript">
>>>>
>>>>         var map, map2, layer;
>>>>         //var url =
>>>> "http://demo01.dmsolutions.ca/mapguide/mapagent/mapagent.fcgi";
>>>>         //you can use this URL when MapGuide OS is installed locally
>>>> 		var url = "http://localhost/mapguide/mapagent/mapagent.fcgi";
>>>>
>>>>         var metersPerUnit = 111319.4908;  //value returned from
>>>> mapguide
>>>>         var inPerUnit = OpenLayers.INCHES_PER_UNIT.m * metersPerUnit;
>>>>         OpenLayers.INCHES_PER_UNIT["dd"] = inPerUnit;
>>>>         OpenLayers.INCHES_PER_UNIT["degrees"] = inPerUnit;
>>>>         OpenLayers.DOTS_PER_INCH = 96;
>>>>
>>>>
>>>>         function init(){
>>>>
>>>>      	var mapBounds = new
>>>> OpenLayers.Bounds(-87.764986990963,43.691398128788,-87.6955215109,43.79752000048);
>>>> 	var fixedScales
>>>> =[1000,1930.6977300000001,3727.5937199999998,7196.8567300000004,13894.95494,26826.95795,51794.746789999997,100000];
>>>>
>>>>             var mapOptions = {
>>>>                 maxExtent: mapBounds,
>>>>                 scales: fixedScales
>>>>             };
>>>> 			
>>>>             map = new OpenLayers.Map( 'map', mapOptions );			
>>>> 			
>>>> 	        //tiled map
>>>>           var tiledParams = {
>>>>               mapdefinition:
>>>> 'Library://Samples/Sheboygan/MapsTiled/Sheboygan.MapDefinition',
>>>>               basemaplayergroupname: "Base Layer Group",
>>>> 	 session: '<%=sessionId%>'
>>>>            }
>>>>
>>>>           var tiledOptions = {
>>>>               units: "dd",
>>>>               singleTile: false
>>>>             }
>>>> 			
>>>>           var tiledLayer = new OpenLayers.Layer.MapGuide(
>>>> "GetTileImage",
>>>> 				url,
>>>> 				tiledParams,
>>>> 				tiledOptions );
>>>>           map.addLayer(tiledLayer);
>>>> 			
>>>>          //un-tiled versions
>>>>
>>>>          var dynamicOverlayOptions = {
>>>>               buffer: 1,
>>>>               singleTile: true,
>>>> 	  isBaseLayer : false,
>>>> 	  visibility : false
>>>>          };
>>>>
>>>>          var mapImageOptions = {
>>>>               buffer: 1,
>>>>               singleTile: true,
>>>> 	 isBaseLayer : true
>>>>          };
>>>>
>>>>         var untiledParams = {
>>>> 	session: '<%=sessionId%>',
>>>>              mapname: 'Sheboygan'
>>>>         };
>>>>
>>>>         var dynamicLayer = new OpenLayers.Layer.MapGuide(
>>>> "GetDynamicMapOverlayImage",
>>>> 	url,
>>>> 	untiledParams,
>>>> 	dynamicOverlayOptions );
>>>>         map.addLayer(dynamicLayer);
>>>> 			
>>>>         var mapImageLayer = new OpenLayers.Layer.MapGuide(
>>>> "GetMapImage",
>>>> 	url,
>>>> 	untiledParams,
>>>> 	mapImageOptions );
>>>>         map.addLayer(mapImageLayer);
>>>>
>>>>         map.zoomToMaxExtent();
>>>>
>>>>         map.addControl(new OpenLayers.Control.MousePosition());
>>>>         map.addControl(new OpenLayers.Control.Scale());
>>>> 			
>>>>         var switcher=new OpenLayers.Control.LayerSwitcher();
>>>>         map.addControl(switcher);
>>>>         switcher.maximizeControl();
>>>>
>>>>         }
>>>>     </script>
>>>>
>>>> The sessionId is returned as parameter to openlayers and the mapname is
>>>> hard-coded as 'Sheboygan'
>>>> only for the untiled version layer.
>>>>
>>>> Also I have tested it with FF and firebug, I have gotten the same
>>>> result
>>>> (see the image attached).
>>>>
>>>> Regards,
>>>>
>>>>
>>>> Kenneth Skovhede, GEOGRAF A/S wrote:
>>>>
>>>>
>>>> How do you return the map name and sessionId to OpenLayers?
>>>>
>>>> If you use Firebug (in Firefox), the "Net" tab will show you any errors
>>>> thrown by MapGuide.
>>>> http://getfirebug.com/
>>>>
>>>> Regards, Kenneth Skovhede, GEOGRAF A/S
>>>>
>>>>
>>>>
>>>> Rodolfo Moreno skrev:
>>>>
>>>>
>>>> Hi all,
>>>> I have tried to port the wiki sample "display mapguide maps using
>>>> openlayers" from PHP to .NET without successful.
>>>>
>>>> The javascript code is the same of the example, the difference is the
>>>> SERVER
>>>> CODE. It's my .NET CODE:
>>>>
>>>> public partial class OLViewer : System.Web.UI.Page
>>>> {
>>>>     public String sessionId;
>>>>     protected void Page_Load(object sender, EventArgs e)
>>>>     {
>>>>         try
>>>>         {
>>>>             // Initialize the web tier
>>>>             Utility utility = new Utility(Request);
>>>>             utility.InitializeWebTier();
>>>>
>>>>             MgUserInformation userInfo = new
>>>> MgUserInformation("Anonymous",
>>>> "");
>>>>
>>>>             MgSiteConnection siteCnn = new MgSiteConnection();
>>>>             siteCnn.Open(userInfo);
>>>>
>>>>             MgSite site = siteCnn.GetSite();
>>>>             sessionId = site.CreateSession();
>>>>
>>>>             userInfo.SetMgSessionId(sessionId);
>>>>
>>>>             MgResourceService resourceService =
>>>> (MgResourceService)siteCnn.CreateService(MgServiceType.ResourceService);
>>>>             MgMappingService mappingService =
>>>> (MgMappingService)siteCnn.CreateService(MgServiceType.MappingService);
>>>>
>>>>             MgResourceIdentifier resId = new
>>>> MgResourceIdentifier("Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition");
>>>>
>>>>             MgMap map = new MgMap();
>>>>             map.Create(resourceService, resId, "Sheboygan");
>>>>
>>>>             MgSelection sel = new MgSelection(map);
>>>>             sel.Save(resourceService, "Sheboygan");
>>>>
>>>>             MgResourceIdentifier mapStateId = new
>>>> MgResourceIdentifier("Session:" + sessionId + "//" + "Sheboygan." +
>>>> MgResourceType.Map);
>>>>             map.Save(resourceService, mapStateId);
>>>>
>>>>         }
>>>>         catch (Exception er)
>>>>         {
>>>>             Response.Write(er.Message);
>>>>         }
>>>>     }
>>>> }
>>>>
>>>> when I run the sample the Page is shown but not the map. (see attached
>>>> image).
>>>> http://n2.nabble.com/file/n1511002/MGusingOL.jpg
>>>>
>>>> I don't know what is the error.
>>>> I'd appreciate so much your suggestions.
>>>>
>>>>
>>>> -----
>>>> Rodolfo Moreno
>>>> CivilEng
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> mapguide-users mailing list
>>>> mapguide-users at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>>
>>>>
>>>>
>>>>
>>>> http://n2.nabble.com/file/n1514643/FirebugTest.jpg
>>>>
>>>> -----
>>>> Rodolfo Moreno
>>>> CivilEng
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> mapguide-users mailing list
>>>> mapguide-users at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>>
>>>>
>>>>       
>>>
>>> -- 
>>> Zac Spitzer -
>>> http://zacster.blogspot.com
>>> http://ennoble.dreamhosters.com/mapguide-central/
>>> +61 405 847 168
>>> _______________________________________________
>>> mapguide-users mailing list
>>> mapguide-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>
>>>
>>>     
>> http://n2.nabble.com/file/n1519783/HTMLfirebugTab.jpg 
>>
>> -----
>> Rodolfo Moreno
>> CivilEng
>>
>>   
> 
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
> 
> 


-----
Rodolfo Moreno
CivilEng

-- 
View this message in context: http://n2.nabble.com/Mapguide-maps-using-openlayers-tp1511002p1520742.html
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list