Display Custom global Mapper
Hi to all,
I would like to display an image, e.g. model.ico, on the map but i obtained a black screen instead.
What should i do to resolve the problem?
The source code is shown as,
void CGM_MapLoaderDlg::LoadVehicleSymbol(){
//Feature Point declaration
GM_LayerHandle_t32 txVectorLayer; //create a new VectorLayer for Point Feature insertion
GM_Projection_t theGeoProj; //store the current Coordinate system
GM_PointFeature_t txPointFeature; //define the properties for the point
GM_PointStyle_t txPointStyle;
GM_VectorFeature_t txVectorFeature;
//Set projection to Geographic (unprojected lat/lon)
::memset( &theGeoProj, 0, sizeof theGeoProj );
theGeoProj.mProjSys = GM_PRJ_GEO;
theGeoProj.mDatum = GM_DATUM_WGS_84;
theGeoProj.mUnit = GM_PRJ_UNIT_ARC_DEGREES;
//create a new custom layer for adding vector features to
txVectorLayer = GM_CreateCustomVectorLayer("TxSymbolLayer", &theGeoProj);
//add a point feature to a loaded vector layer or custom vector layer
GM_AddCustomSymbol("P:\\Map\\model.ico","TX_SYMBOL");
txPointStyle.mSymbolName = "TX_SYMBOL";
txPointStyle.mScale = 1;
txPointStyle.mRotation = 0;
txVectorFeature.mName = "TxVehicleSymbol";
txVectorFeature.mDesc = "TxVehicleSymbol";
txVectorFeature.mClass = AFC_UNKNOWN;
txPointFeature.mFeatureInfo = txVectorFeature;
txPointFeature.mPointStyle = txPointStyle;
txPointFeature.mPos.mX = 103.657977f; //Lon
txPointFeature.mPos.mY = 1.369478f; //Lat
mMapWindow.AddLayer(txVectorLayer);
//destory the pointer after used
GM_CloseLayer(txVectorLayer);
}
Thanks for your help,
ZP
I would like to display an image, e.g. model.ico, on the map but i obtained a black screen instead.
What should i do to resolve the problem?
The source code is shown as,
void CGM_MapLoaderDlg::LoadVehicleSymbol(){
//Feature Point declaration
GM_LayerHandle_t32 txVectorLayer; //create a new VectorLayer for Point Feature insertion
GM_Projection_t theGeoProj; //store the current Coordinate system
GM_PointFeature_t txPointFeature; //define the properties for the point
GM_PointStyle_t txPointStyle;
GM_VectorFeature_t txVectorFeature;
//Set projection to Geographic (unprojected lat/lon)
::memset( &theGeoProj, 0, sizeof theGeoProj );
theGeoProj.mProjSys = GM_PRJ_GEO;
theGeoProj.mDatum = GM_DATUM_WGS_84;
theGeoProj.mUnit = GM_PRJ_UNIT_ARC_DEGREES;
//create a new custom layer for adding vector features to
txVectorLayer = GM_CreateCustomVectorLayer("TxSymbolLayer", &theGeoProj);
//add a point feature to a loaded vector layer or custom vector layer
GM_AddCustomSymbol("P:\\Map\\model.ico","TX_SYMBOL");
txPointStyle.mSymbolName = "TX_SYMBOL";
txPointStyle.mScale = 1;
txPointStyle.mRotation = 0;
txVectorFeature.mName = "TxVehicleSymbol";
txVectorFeature.mDesc = "TxVehicleSymbol";
txVectorFeature.mClass = AFC_UNKNOWN;
txPointFeature.mFeatureInfo = txVectorFeature;
txPointFeature.mPointStyle = txPointStyle;
txPointFeature.mPos.mX = 103.657977f; //Lon
txPointFeature.mPos.mY = 1.369478f; //Lat
mMapWindow.AddLayer(txVectorLayer);
//destory the pointer after used
GM_CloseLayer(txVectorLayer);
}
Thanks for your help,
ZP
Comments
-
ZP,
It doesn't look like you ever add the point to the layer. Use GM_AddPointToVectorLayer to add your point feature to the txVectorLayer, then see if it draws.
Let me know if I can be of further assistance.
Thanks,
Mike
Global Mapper Guru
gmsupport@bluemarblegeo.com
http://www.globalmapper.com -
Thank for the tip.
I have inserted the GM_AddPointToVectorLayer into the program but the symbol is still not drawn.
Some of the codes are also amended because they have caused <Bad ptr> errors.
This is the amended program:
void CGM_MapLoaderDlg::LoadVehicleSymbol(){
//Feature Point declaration
GM_LayerHandle_t32 txVectorLayer; //create a new VectorLayer for Point Feature insertion
GM_Projection_t theGeoProj; //store the current Coordinate system
GM_PointFeature_t txPointFeature; //define the properties for the point
GM_PointStyle_t txPointStyle;
GM_VectorFeature_t txVectorFeature;
//Set projection to Geographic (unprojected lat/lon)
::memset( &theGeoProj, 0, sizeof theGeoProj );
theGeoProj.mProjSys = GM_PRJ_GEO;
theGeoProj.mDatum = GM_DATUM_WGS_84;
theGeoProj.mUnit = GM_PRJ_UNIT_ARC_DEGREES;
//define the Point Feature used
GM_AddCustomSymbol("P:\\Map\\model.ico","TX_SYMBOL");
::memset(&txPointStyle,0,sizeof txPointStyle);
txPointStyle.mSymbolName = "TX_SYMBOL";
txPointStyle.mScale = 1;
txPointStyle.mRotation = 0;
::memset( &txVectorFeature, 0, sizeof txVectorFeature );
txVectorFeature.mName = "TxVehicleSymbol";
txVectorFeature.mDesc = "TxVehicleSymbol";
txVectorFeature.mClass = AFC_UNKNOWN;
txVectorFeature.mAttrList = NULL;
txVectorFeature.mNumAttrs = 0;
txPointFeature.mFeatureInfo = txVectorFeature;
txPointFeature.mPointStyle = txPointStyle;
txPointFeature.mPos.mX = 103.657977f; //Lon
txPointFeature.mPos.mY = 1.369478f; //Lat
//create a new custom layer for adding vector features to
txVectorLayer = GM_CreateCustomVectorLayer("TxSymbolLayer", &theGeoProj);
mMapWindow.AddLayer(txVectorLayer);
//destory the pointer after used
GM_CloseLayer(txVectorLayer);
}
Thank for your time,
ZP -
Sorry, I have posted the wrong set of code.
the last few line should be these:
//create a new custom layer for adding vector features to
txVectorLayer = GM_CreateCustomVectorLayer("TxSymbolLayer", &theGeoProj); GM_AddPointToVectorLayer(txVectorLayer,&txPointFeature,GM_AddFeature_UseDefaultStyle);
mMapWindow.AddLayer(txVectorLayer);
//destory the pointer after used
GM_CloseLayer(txVectorLayer); -
It looks like you are closing the layer with the GM_CloseLayer call, so it will no longer be available for the draw. You don't want to close a layer until you are done with it, as closing the layer completely removes it and all features in it.
Let me know if I can be of further assistance.
Thanks,
Mike
Global Mapper Guru
gmsupport@bluemarblegeo.com
http://www.globalmapper.com -
Thank for the explanation.
An image was displayed on the screen but it's not the custom symbol which i have declared. It seemed to be a built-in symbol called "school". I tried to amend the scale and other properties of the PointStyle but none has any display effect.
Other problem i encountered is when i tried to load the symbol into the ECW map. The "school" symbol disappear but the map appeared. Could it be due to the first problem or there is more bugs in my program?
Thanks for your time,
ZP
This is the update copy of my program:
//declaration
GM_LayerHandle_t32 txVectorLayer; //create a new VectorLayer for Point Feature insertion
GM_Projection_t theGeoProj; //store the current Coordinate system
GM_PointFeature_t txPointFeature;
//Configure the projection
::memset( &theGeoProj, 0, sizeof theGeoProj );
theGeoProj.mProjSys = GM_PRJ_GEO;
theGeoProj.mDatum = GM_DATUM_WGS_84;
theGeoProj.mUnit = GM_PRJ_UNIT_ARC_DEGREES;
//define the Point Feature used
GM_AddCustomSymbol("P:\\Map\\model.ico","TX_SYMBOL");
::memset( &txPointFeature, 0, sizeof(txPointFeature));
txPointFeature.mPos.mX = 103.657977f;
txPointFeature.mPos.mY = 1.369478f;
txPointFeature.mPointStyle.mScale = 10;
txPointFeature.mPointStyle.mSymbolName = "TX_SYMBOL";
txPointFeature.mPointStyle.mFont.mFaceName = "Arial";
txPointFeature.mPointStyle.mFont.mColor = RGB(255,0,0);
txPointFeature.mPointStyle.mFont.mPointSize = 14;
txPointFeature.mPointStyle.mFont.mUnderline = TRUE;
txPointFeature.mPointStyle.mDrawLabel = TRUE;
txPointFeature.mPointStyle.mDrawLabelAlways = TRUE;
txPointFeature.mPointStyle.mRotation = 0;
txPointFeature.mFeatureInfo.mName = ""; //display Text
txPointFeature.mFeatureInfo.mDesc = "TxVehicleSymbol";
txPointFeature.mFeatureInfo.mClass = AFC_UNKNOWN;
//Load Map
mMapWindow.LoadLayer("P:\\Map\\Trial.ecw");
GM_MapWindow::LayerHandleList_t MapLayer = mMapWindow.GetLayerList();
GM_AddPointToVectorLayer(MapLayer[0],&txPointFeature,GM_AddFeature_UseDefaultStyle); -
There are a couple of problems. First of all you are assigning the point feature classification to AFC_UNKNOWN, which is an area type not a point type. Use PFC_UNKNOWN for the point type. Also, pass in 0 rather than GM_AddFeature_UseDefaultStyle. If you pass in the default style flag then the style information that you provide is entirely ignored and the default style for the type is used, which is not what you want.
Let me know if I can be of further assistance.
Thanks,
Mike
Global Mapper Guru
gmsupport@bluemarblegeo.com
http://www.globalmapper.com
Categories
- 12.7K All Categories
- 5.6K Features Discussion
- 342 Downloading Imagery
- 1.3K Elevation Data
- 380 Georeferencing Imagery Discussion
- 628 GM Script Language
- 53 User Scripts
- 113 GPS Features
- 414 Projection Questions
- 819 Raster Data
- 1.3K Vector Data
- 6.6K Support
- 177 Announcement and News
- 908 Bug Report
- 558 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 562 Other Discussion
- 129 GIS Data Sources
- 27 Global Mapper Showcase
- 233 How I use Global Mapper
- 107 Global Mapper Forum Website