[mapguide-users] Mapguide maps using openlayers
Kenneth Skovhede, GEOGRAF A/S
ks at geograf.dk
Tue Nov 18 10:41:12 EST 2008
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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20081118/a8911167/attachment.html
More information about the mapguide-users
mailing list