How to troubleshoot an issue in which ArcGIS Runtime SDK for Android Chinese annotations cannot be displayed

Source: Internet
Author: User
Tags sqlite database

Since the 10.2 release, I have been plagued by the Chinese annotations of ArcGIS Runtime SDK for Android. Whether it is a graphic text symbol residing in memory, or a new textsymbol in the offline geodatabase, it cannot be displayed as long as it is related to Chinese. Every time I received a user's call, I can only be very official hasty response, the document clearly stated that this limit ah, there is no way to do it; we recommend that you create an offline cache for your labeling layer, and that your Android development experience is so rich that you can draw your own text to achieve it, and so on. In fact, I also think that Esri's omission is too sorry for the vast number of Chinese users.

Fortunately for the graphic Chinese textsymbol display quickly found a convenient method, but also a preliminary explanation. No more nonsense, just a simple snippet of code.

1 //creating point Geometries2Point tappoint =mmapview.tomappoint (x, y);3 4 //Creating text Symbols5String ShowLabel = "haha, Chinese callout graphic point";6Textsymbol Taptextsymbol =NewTextsymbol (28, ShowLabel, color.blue);7Taptextsymbol.setfontfamily ("Droidsansfallback.ttf");8 9 //passing in point geometry and text symbols to build graphicTenGraphic tapgraphic =NewGraphic (Tappoint, taptextsymbol); One  A //Add the created graphic to the Graphicslayer -Glayer.addgraphic (tapgraphic);

Yes, the key to the problem is the designation of the font, that is, calling setfontfamily () to accurately identify the correct font . Most Android devices will be installed by default Droidsansfallback.ttf This font, you can get it.

Graphic problem solved, next, should pay attention to offline Geodatabase labeling, after all, this format is the biggest bright spot of 10.2.X, is also the mobile application needs. After all, the likelihood of a smooth networking in field operations is zero. Awaited finally appeared, but still genteel picked up the pipa-Chinese mark it? What about the Chinese label?

One by one user demand forced me to start a new round of attempts. For the same data, why the English and the numbers can be displayed normally, and alone Chinese annotations cannot be displayed? First of all, using the Sqlitemanager provided by Firefox to view the feature table, the data is not a problem, then 80%~90% is the font setting problem. Android device is installed by default Droidsansfallback.ttf This can support the Chinese font, then refer to the ArcGIS for server font resolution, install this font and restart the machine, create an mxd and select this font, Then create the geodatabase. Repeated three times the toss proof: completely invalid Ah, even garbled. No words.

In September, the ESRI developer team finally verified that the offline geodatabase that were downloaded after several properties were updated for the portal for ArcGIS hosted feature service can be displayed correctly in Chinese. This news has finally aroused my morale again, then look for the difference between the two. After half a day of unremitting efforts, the truth revealed.

First, use Sqlitemanager to open the offline geodatabase that you created.

Second, the most critical step is to find the list of Gdb_serviceitems open and double-click to view

It is clear that fontfamily in both ItemInfo and Drawinginfo are correctly set to Droid Sans Fallback. However, in this case, the Chinese annotation still cannot be displayed. All you need to do is edit the ItemInfo field and change the family to Droidsansfallback.ttf, as follows:

after loading the modified geodatabase again, the Chinese annotation finally appeared.

Family before modification:

Family modified:

Yes, you're right, that's stupid. The equivalent you hear Zhang San name, completely do not know who, must see the Buddha, only clear, originally is he ah, I know, I know, hehe, hehe ...

Since the offline geodatabase created by ArcMap can display Chinese annotations correctly. So analogy, for offline Geodatabase obtained by the online service, only need code implementation 1) Connect to this SQLite database, 2) Find the ItemInfo field of the Gdb_serviceitem table, 3) Modify this property value. The concrete realization is to excuse everybody. This is the small chapter.

tabloid, tabloid :

According to ESRI's unofficial channel, the Quarz version, launched next March, will fundamentally address this issue. Small series no longer have to worry about the Chinese annotation in the application.

How to troubleshoot an issue in which ArcGIS Runtime SDK for Android Chinese annotations cannot be displayed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.